aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/cli/help_test.v
blob: 62cb37e63974b60bd28cc08de28f53cef4d2954b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
'
}