cli: show help for empty root command (#6636)
parent
3c2202572b
commit
dea8662d6b
|
@ -185,6 +185,12 @@ fn (mut cmd Command) parse_commands() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if cmd.is_root() && int(cmd.execute) == 0 {
|
||||||
|
if !cmd.disable_help {
|
||||||
|
cmd.execute_help()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
// if no further command was found, execute current command
|
// if no further command was found, execute current command
|
||||||
if cmd.required_args > 0 {
|
if cmd.required_args > 0 {
|
||||||
if cmd.required_args > cmd.args.len {
|
if cmd.required_args > cmd.args.len {
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
import os
|
|
||||||
import cli {Command}
|
import cli {Command}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
mut cmd := Command {}
|
mut cmd := Command {
|
||||||
cmd.parse(os.args)
|
name: 'cmd'
|
||||||
|
}
|
||||||
|
cmd.add_command({
|
||||||
|
name: 'foo'
|
||||||
|
})
|
||||||
|
cmd.parse(['', 'cmd', 'foo'])
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
Usage: [flags] [commands]
|
||||||
|
|
||||||
|
Flags:
|
||||||
|
-help Prints help information.
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
help Prints help information.
|
|
@ -0,0 +1,7 @@
|
||||||
|
import cli {Command}
|
||||||
|
import os
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
mut cmd := Command {}
|
||||||
|
cmd.parse(os.args)
|
||||||
|
}
|
Loading…
Reference in New Issue