Skip to content

Commit

Permalink
fix: panic when providing an empty string as an argument
Browse files Browse the repository at this point in the history
  • Loading branch information
aisbergg committed Aug 24, 2022
1 parent b837354 commit 886a02d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func (c *Command) innerDispatch(args []string) (err error) {
name := args[0]

// ensure is not an option
if name[0] != '-' {
if name != "" && name[0] != '-' {
name = c.ResolveAlias(name)

// is valid sub command
Expand All @@ -452,7 +452,7 @@ func (c *Command) innerDispatch(args []string) (err error) {
return sub.innerDispatch(args[1:])
}

// no arguments, name is not founded subcommand
// is not a sub command and has no arguments -> error
if !c.HasArguments() {
// fire events
if stop := c.Fire(EvtCmdSubNotFound, name); stop {
Expand All @@ -464,8 +464,6 @@ func (c *Command) innerDispatch(args []string) (err error) {

color.Error.Tips("subcommand '%s' - not found on the command", name)
}
} else {
name = "" // reset var
}
}

Expand Down

0 comments on commit 886a02d

Please sign in to comment.