Skip to content

Commit

Permalink
cli: fix custom help without execute handler (#18732)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Jul 4, 2023
1 parent 7279e49 commit 5d269ba
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions vlib/cli/command.v
Expand Up @@ -294,10 +294,12 @@ fn (cmd Command) check_required_flags() {
pub fn (cmd Command) execute_help() {
if cmd.commands.contains('help') {
help_cmd := cmd.commands.get('help') or { return } // ignore error and handle command normally
help_cmd.execute(help_cmd) or { panic(err) }
} else {
print(cmd.help_message())
if !isnil(help_cmd.execute) {
help_cmd.execute(help_cmd) or { panic(err) }
return
}
}
print(cmd.help_message())
}

// execute_help executes the callback registered
Expand Down

0 comments on commit 5d269ba

Please sign in to comment.