Skip to content

Commit 8b26e82

Browse files
committed
Add --list-regions
1 parent f54daeb commit 8b26e82

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

data.go

+11
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,15 @@ func printKnownFiltersInfo() {
6969
}
7070

7171
fmt.Println()
72+
73+
return
74+
}
75+
76+
func printRegionInfo() {
77+
fmt.Println("Valid Regions:")
78+
for region, code := range regionData {
79+
fmt.Println(" ", region, "\t", goseq.RegionNames[code])
80+
}
81+
fmt.Println()
82+
return
7283
}

masterctx.go

+28-5
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212
)
1313

1414
type MasterQueryOptions struct {
15-
Region string `long:"region" short:"r" default:"USW" description:"Region code to get results for. One of USE, USW, SA, EU, AS, AU, ME, AF, OTHER."`
15+
Region string `long:"region" short:"r" default:"USW" description:"Region code to get results for. See --list-regions"`
1616
Async bool `long:"async" short:"a" default:"true" long:"async" description:"Allow async sub-querying of Source Servers to get info."`
17-
Fields string `long:"fields" default:"ip=21,name" description:"The fields to be included. Optionally includes the min-length space. See --showfields" `
17+
Fields string `long:"fields" default:"ip=21,name" description:"The fields to be included. Optionally includes the min-length space. See --list-fields" `
1818
// TODO(hunter): Add this
1919
ShowFields bool `long:"show-fields" default:"false" description:"Print details on each available field."`
2020
// TODO(hunter): Add this
@@ -30,7 +30,8 @@ type MasterQueryOptions struct {
3030
// TODO(hunter): Add this
3131
Filters map[string]string `long:"filter" short:"f" description:"Filters to use. See --list-filters"`
3232
// TODO(hunter): Add this
33-
ListFilters bool `long:"list-filters" default:"false" description:"List known filters."`
33+
ListFilters bool `long:"list-filters" default:"false" description:"List known filters." group:"Lists"`
34+
ListRegions bool `long:"list-regions" default:"false" description:"List Regions." group:"Lists"`
3435
}
3536

3637
var masterOptions MasterQueryOptions
@@ -48,11 +49,12 @@ type SvResponse struct {
4849
info goseq.ServerInfo
4950
}
5051

52+
type infoPrinter func()
53+
5154
func masterctx() {
5255
log.SetFlags(0)
5356

54-
if masterOptions.ListFilters {
55-
printKnownFiltersInfo()
57+
if printInfo() {
5658
return
5759
}
5860

@@ -267,3 +269,24 @@ type ErrorCount struct {
267269
err error
268270
count int
269271
}
272+
273+
func printInfo() (done bool) {
274+
done = false
275+
276+
infos := []struct {
277+
f infoPrinter
278+
enabled bool
279+
}{
280+
{printKnownFiltersInfo, masterOptions.ListFilters},
281+
{printRegionInfo, masterOptions.ListRegions},
282+
}
283+
284+
for _, info := range infos {
285+
if info.enabled {
286+
info.f()
287+
done = true
288+
}
289+
}
290+
291+
return
292+
}

0 commit comments

Comments
 (0)