Cli now displays usage information for subcommands correctly
This commit is contained in:
parent
367f4c5d34
commit
39f62a3d3f
@ -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]")
|
||||
|
Loading…
Reference in New Issue
Block a user