diff --git a/goutil.go b/goutil.go index ef06323..293d567 100644 --- a/goutil.go +++ b/goutil.go @@ -174,7 +174,7 @@ func NewCommand(cmd string, f CommandFunc, desc string) Command { type commandCollection map[string]Command -func UsageAndExit(cmds commandCollection) { +func usageAndExit(cmds []Command) { fmt.Println(os.Args[0]) fmt.Println() fmt.Println("Possible commands:") @@ -194,16 +194,16 @@ func Execute(possibleCommands []Command) error { } arglen := len(os.Args) if arglen <= 1 { - UsageAndExit(commands) + usageAndExit(possibleCommands) } cmdStr := os.Args[1] if cmdStr == "help" { if arglen == 2 { - UsageAndExit(commands) + usageAndExit(possibleCommands) } else { cmd, ok := commands[os.Args[2]] if !ok { - UsageAndExit(commands) + usageAndExit(possibleCommands) } else { fmt.Println("Description of " + cmd.cmd + ":") fmt.Println(" " + cmd.desc) @@ -219,7 +219,7 @@ func Execute(possibleCommands []Command) error { } cmd, ok := commands[cmdStr] if !ok { - UsageAndExit(commands) + usageAndExit(possibleCommands) } if cmd.flags != nil { cmd.flags.Parse(os.Args[2:])