Skip to content

Commit

Permalink
adding fix for default command panic
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasCarioca committed Oct 4, 2021
1 parent d19992b commit 261fbae
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ func (a *App) AddCommand(name string, command Command) {
}

func (a *App) Run() error {
cmd, ok := a.commands[os.Args[1]]
if ok {
return cmd.Run()
if len(os.Args) > 1 {
cmd, ok := a.commands[os.Args[1]]
if ok {
return cmd.Run()
}
}

cmd, ok = a.commands["default"]
cmd, ok := a.commands["default"]
if ok {
return cmd.Run()
}
Expand Down

0 comments on commit 261fbae

Please sign in to comment.