Print tools in alphabetical order when no util choosen.
This commit is contained in:
parent
a4bb5d703e
commit
d8d05cb807
1 changed files with 13 additions and 2 deletions
|
@ -5,6 +5,7 @@ import(
|
||||||
"os"
|
"os"
|
||||||
path "path/filepath"
|
path "path/filepath"
|
||||||
"flag"
|
"flag"
|
||||||
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Flags struct {
|
type Flags struct {
|
||||||
|
@ -34,9 +35,19 @@ func Main(name string, m Tools) {
|
||||||
args = os.Args[:]
|
args = os.Args[:]
|
||||||
} else {
|
} else {
|
||||||
if len(os.Args)<2 {
|
if len(os.Args)<2 {
|
||||||
for k, v := range m {
|
keys := make([]string, len(m))
|
||||||
fmt.Printf("%s:\t%s\n", k, v.Desc)
|
i := 0
|
||||||
|
for k, _ := range m {
|
||||||
|
keys[i] = k
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
|
||||||
|
for _, k := range keys {
|
||||||
|
tool := m[k]
|
||||||
|
fmt.Printf("%s: %s\n", k, tool.Desc)
|
||||||
|
}
|
||||||
|
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
utilName = os.Args[1]
|
utilName = os.Args[1]
|
||||||
|
|
Loading…
Reference in a new issue