mirror of
https://github.com/vlang/v.git
synced 2025-09-15 07:22:27 +03:00
cli: fix bug that caused help to panic (#11157)
This commit is contained in:
parent
12fb4655f5
commit
9c74fb0449
2 changed files with 71 additions and 1 deletions
65
vlib/cli/help_test.v
Normal file
65
vlib/cli/help_test.v
Normal file
|
@ -0,0 +1,65 @@
|
|||
module cli
|
||||
|
||||
fn test_help_message() {
|
||||
mut cmd := Command{
|
||||
name: 'command'
|
||||
description: 'description'
|
||||
commands: [
|
||||
Command{
|
||||
name: 'sub'
|
||||
description: 'subcommand'
|
||||
},
|
||||
Command{
|
||||
name: 'sub2'
|
||||
description: 'another subcommand'
|
||||
},
|
||||
]
|
||||
flags: [
|
||||
Flag{
|
||||
flag: .string
|
||||
name: 'str'
|
||||
description: 'str flag'
|
||||
},
|
||||
Flag{
|
||||
flag: .bool
|
||||
name: 'bool'
|
||||
description: 'bool flag'
|
||||
abbrev: 'b'
|
||||
},
|
||||
Flag{
|
||||
flag: .string
|
||||
name: 'required'
|
||||
abbrev: 'r'
|
||||
required: true
|
||||
},
|
||||
]
|
||||
}
|
||||
assert cmd.help_message() == r'Usage: command [flags] [commands]
|
||||
|
||||
description
|
||||
|
||||
Flags:
|
||||
-str str flag
|
||||
-b -bool bool flag
|
||||
-r -required (required)
|
||||
|
||||
Commands:
|
||||
sub subcommand
|
||||
sub2 another subcommand
|
||||
'
|
||||
|
||||
cmd.posix_mode = true
|
||||
assert cmd.help_message() == r'Usage: command [flags] [commands]
|
||||
|
||||
description
|
||||
|
||||
Flags:
|
||||
--str str flag
|
||||
-b --bool bool flag
|
||||
-r --required (required)
|
||||
|
||||
Commands:
|
||||
sub subcommand
|
||||
sub2 another subcommand
|
||||
'
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue