Skip to content

Commit

Permalink
fix: handling of CmdNotFound errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aisbergg committed Aug 8, 2022
1 parent bfdd98d commit 0c89eea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 8 additions & 5 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,15 @@ func (app *App) prepareRun() (code int, name string) {
if app.inputName == "" {
Logf(VerbDebug, "input the command is not an registered: %s", name)

if stop := app.Fire(EvtAppCmdNotFound, name); stop == false {
stop = app.Fire(EvtCmdNotFound, name)
if stop == false {
app.showCommandTips(name)
}
// fire events
if stop := app.Fire(EvtAppCmdNotFound, name); stop {
return
}
if stop := app.Fire(EvtCmdNotFound, name); stop {
return
}

app.showCommandTips(name)
return
}

Expand Down
6 changes: 2 additions & 4 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,10 @@ func (c *Command) innerDispatch(args []string) (err error) {
// no arguments, name is not founded subcommand
if !c.HasArguments() {
// fire events
stop := c.Fire(EvtCmdSubNotFound, name)
if stop == true {
if stop := c.Fire(EvtCmdSubNotFound, name); stop {
return
}

if stop = c.Fire(EvtCmdNotFound, name); stop == false {
if stop := c.Fire(EvtCmdNotFound, name); stop {
return
}

Expand Down

0 comments on commit 0c89eea

Please sign in to comment.