v / vlib / cli
Raw file | 65 loc (57 sloc) | 1.08 KB | Latest commit hash 9c74fb044
1module cli
2
3fn test_help_message() {
4 mut cmd := Command{
5 name: 'command'
6 description: 'description'
7 commands: [
8 Command{
9 name: 'sub'
10 description: 'subcommand'
11 },
12 Command{
13 name: 'sub2'
14 description: 'another subcommand'
15 },
16 ]
17 flags: [
18 Flag{
19 flag: .string
20 name: 'str'
21 description: 'str flag'
22 },
23 Flag{
24 flag: .bool
25 name: 'bool'
26 description: 'bool flag'
27 abbrev: 'b'
28 },
29 Flag{
30 flag: .string
31 name: 'required'
32 abbrev: 'r'
33 required: true
34 },
35 ]
36 }
37 assert cmd.help_message() == r'Usage: command [flags] [commands]
38
39description
40
41Flags:
42 -str str flag
43 -b -bool bool flag
44 -r -required (required)
45
46Commands:
47 sub subcommand
48 sub2 another subcommand
49'
50
51 cmd.posix_mode = true
52 assert cmd.help_message() == r'Usage: command [flags] [commands]
53
54description
55
56Flags:
57 --str str flag
58 -b --bool bool flag
59 -r --required (required)
60
61Commands:
62 sub subcommand
63 sub2 another subcommand
64'
65}