From 70c0204128912bc833e44b8fb78e020ccb30b49d Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Tue, 16 Mar 2021 13:09:27 +0000 Subject: [PATCH] setup comamnd line argument parsing --- browser.go | 3 +++ stations.go | 33 ++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 browser.go diff --git a/browser.go b/browser.go new file mode 100644 index 0000000..1110061 --- /dev/null +++ b/browser.go @@ -0,0 +1,3 @@ +package main + + diff --git a/stations.go b/stations.go index c6dbd13..4810192 100644 --- a/stations.go +++ b/stations.go @@ -1,12 +1,35 @@ package main -import "fmt" +import ( + "flag" + "fmt" + "os" +) func main(){ - fmt.Println(api()) - fmt.Println(player()) - fmt.Println(options()) - fmt.Println(maxitems()) + fmt.Println("Configuration values:") + fmt.Println("api url: ", api()) + fmt.Println("player command: ", player()) + fmt.Println("player options: ", options()) + fmt.Println("maximum menu items: ", maxitems()) + argCount := len(os.Args[1:]) + + var ( + name string + country string + state string + tags string + ) + + flag.StringVar(&name, "n", "", "Station name (or identifier).") + flag.StringVar(&country, "c", "", "Home country.") + flag.StringVar(&state, "s", "", "Home state (if in the United States).") + flag.StringVar(&tags, "t", "", "Tag (or comma-separated tag list)") + flag.Parse() + + if argCount == 0 { + flag.Usage() + } } \ No newline at end of file