brain storm: allow toggling of down station display; default to no
This commit is contained in:
parent
35819226bf
commit
90907d0d05
@ -70,7 +70,7 @@ func pruneStations(stations []stationRecord) []stationRecord {
|
|||||||
return filteredStations
|
return filteredStations
|
||||||
}
|
}
|
||||||
|
|
||||||
func StationSearch(name string, country string, state string, tags string) ([]stationRecord, error) {
|
func StationSearch(name string, country string, state string, tags string, notok bool) ([]stationRecord, error) {
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
if name != ""{
|
if name != ""{
|
||||||
params.Add("name", name)
|
params.Add("name", name)
|
||||||
@ -89,6 +89,9 @@ func StationSearch(name string, country string, state string, tags string) ([]st
|
|||||||
if err != nil{
|
if err != nil{
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if notok{
|
||||||
|
return stations, err
|
||||||
|
} // otherwise prune the list
|
||||||
prunedStations := pruneStations(stations) // eliminate stations that are reporting down.
|
prunedStations := pruneStations(stations) // eliminate stations that are reporting down.
|
||||||
return prunedStations, err
|
return prunedStations, err
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,12 @@ func main(){
|
|||||||
country string
|
country string
|
||||||
state string
|
state string
|
||||||
tags string
|
tags string
|
||||||
|
notok bool
|
||||||
)
|
)
|
||||||
flag.Usage = func() {
|
flag.Usage = func() {
|
||||||
fmt.Printf("Usage: \n")
|
fmt.Printf("Usage: \n")
|
||||||
fmt.Printf(" gostations ")
|
fmt.Printf(" gostations ")
|
||||||
fmt.Printf(" [-n \"name\"] [-c \"home country\"] [-s \"home state\"] [-t \"ordered,tag,list\"]\n")
|
fmt.Printf(" [-n \"name\"] [-c \"home country\"] [-s \"home state\"] [-t \"ordered,tag,list\"] [-x]\n")
|
||||||
flag.PrintDefaults()
|
flag.PrintDefaults()
|
||||||
fmt.Printf(" -h (or none)\n")
|
fmt.Printf(" -h (or none)\n")
|
||||||
fmt.Printf("\tThis help message\n")
|
fmt.Printf("\tThis help message\n")
|
||||||
@ -27,17 +28,19 @@ func main(){
|
|||||||
flag.StringVar(&country, "c", "", "Home country.")
|
flag.StringVar(&country, "c", "", "Home country.")
|
||||||
flag.StringVar(&state, "s", "", "Home state (if in the United States).")
|
flag.StringVar(&state, "s", "", "Home state (if in the United States).")
|
||||||
flag.StringVar(&tags, "t", "", "Tag (or comma-separated tag list)")
|
flag.StringVar(&tags, "t", "", "Tag (or comma-separated tag list)")
|
||||||
|
flag.BoolVar(¬ok, "x", false,"If toggled, will show stations that are down")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if argCount == 0 {
|
if argCount == 0 {
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
stations, _ := StationSearch(name, country, state, tags)
|
stations, _ := StationSearch(name, country, state, tags, notok)
|
||||||
fmt.Println(len(stations))
|
|
||||||
for _, station := range stations {
|
for _, station := range stations {
|
||||||
fmt.Printf("%+v\n", station)
|
fmt.Printf("%+v\n", station)
|
||||||
}
|
}
|
||||||
|
fmt.Println(len(stations))
|
||||||
|
|
||||||
//mainMenu = RadioMenu(station_list)
|
//mainMenu = RadioMenu(station_list)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user