diff --git a/cli/cli.go b/cli/cli.go index 2b3b2e3..447475e 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -68,7 +68,7 @@ func (this *Cli) AddSub (name string, sub *Cli) { func (this *Cli) Parse (args []string) (*Cli, error) { // try to find a sub-command if this.Sub != nil && len(args) > 0 { - if sub, ok := this.Sub[args[0]]; ok { + if sub, ok := this.Sub[args[1]]; ok { return sub.Parse(args[1:]) } } @@ -184,10 +184,10 @@ func (this *Cli) LongFlag (long string) (*Flag, bool) { func (this *Cli) Usage () { // syntax fmt.Fprint(os.Stderr, "Usage:") - if this.Super != "" { - fmt.Fprint(os.Stderr, "", this.Super) - } fmt.Fprint(os.Stderr, " ", os.Args[0]) + if this.Super != "" { + fmt.Fprint(os.Stderr, " ", this.Super) + } hasSubCommands := this.Sub != nil && len(this.Sub) > 0 if hasSubCommands { fmt.Fprint(os.Stderr, " [COMMAND]")