2021-03-16 12:32:59 +00:00
|
|
|
package main
|
|
|
|
|
2021-03-16 13:09:27 +00:00
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
2021-03-16 12:32:59 +00:00
|
|
|
|
2021-03-17 07:17:09 +00:00
|
|
|
func precheck(){
|
|
|
|
if !isInstalled(player()){
|
|
|
|
fmt.Printf("%s is either not installed, or not on your $PATH. Cannot continue.\n", player())
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-16 12:32:59 +00:00
|
|
|
func main(){
|
2021-03-16 13:09:27 +00:00
|
|
|
argCount := len(os.Args[1:])
|
|
|
|
|
|
|
|
var (
|
|
|
|
name string
|
|
|
|
country string
|
|
|
|
state string
|
|
|
|
tags string
|
2021-03-16 20:17:10 +00:00
|
|
|
notok bool
|
2021-03-16 13:09:27 +00:00
|
|
|
)
|
2021-03-16 19:27:52 +00:00
|
|
|
flag.Usage = func() {
|
|
|
|
fmt.Printf("Usage: \n")
|
|
|
|
fmt.Printf(" gostations ")
|
2021-03-16 20:17:10 +00:00
|
|
|
fmt.Printf(" [-n \"name\"] [-c \"home country\"] [-s \"home state\"] [-t \"ordered,tag,list\"] [-x]\n")
|
2021-03-16 19:27:52 +00:00
|
|
|
flag.PrintDefaults()
|
|
|
|
fmt.Printf(" -h (or none)\n")
|
|
|
|
fmt.Printf("\tThis help message\n")
|
|
|
|
}
|
2021-03-16 13:09:27 +00:00
|
|
|
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)")
|
2021-03-16 20:17:10 +00:00
|
|
|
flag.BoolVar(¬ok, "x", false,"If toggled, will show stations that are down")
|
2021-03-16 13:09:27 +00:00
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
if argCount == 0 {
|
|
|
|
flag.Usage()
|
2021-03-16 20:17:10 +00:00
|
|
|
os.Exit(0)
|
2021-03-16 13:09:27 +00:00
|
|
|
}
|
2021-03-17 07:17:09 +00:00
|
|
|
precheck()
|
2021-03-16 12:32:59 +00:00
|
|
|
|
2021-03-16 20:17:10 +00:00
|
|
|
stations, _ := StationSearch(name, country, state, tags, notok)
|
2021-03-16 23:06:20 +00:00
|
|
|
menu := RadioMenu(stations)
|
|
|
|
err := menu.Run()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2021-03-16 14:46:28 +00:00
|
|
|
|
2021-03-16 12:32:59 +00:00
|
|
|
}
|