From 5d269ba703415ac7a17df1fa9c4fa65b94127a9b Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Tue, 4 Jul 2023 00:48:53 -0300 Subject: [PATCH] cli: fix custom help without execute handler (#18732) --- vlib/cli/command.v | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vlib/cli/command.v b/vlib/cli/command.v index cdd760e893..178e22df7a 100644 --- a/vlib/cli/command.v +++ b/vlib/cli/command.v @@ -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