• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Following are tests for the interop examples in this directory.
2
3## Augment Args
4
5```console
6$ interop_augment_args
7Value of built: false
8Value of derived via ArgMatches: false
9Value of derived: DerivedArgs {
10    derived: false,
11}
12
13```
14
15```console
16$ interop_augment_args -b --derived
17Value of built: true
18Value of derived via ArgMatches: true
19Value of derived: DerivedArgs {
20    derived: true,
21}
22
23```
24
25```console
26$ interop_augment_args -d --built
27Value of built: true
28Value of derived via ArgMatches: true
29Value of derived: DerivedArgs {
30    derived: true,
31}
32
33```
34
35```console
36$ interop_augment_args --unknown
37? failed
38error: Found argument '--unknown' which wasn't expected, or isn't valid in this context
39
40	If you tried to supply `--unknown` as a value rather than a flag, use `-- --unknown`
41
42USAGE:
43    interop_augment_args[EXE] [OPTIONS]
44
45For more information try --help
46
47```
48
49## Augment Subcommands
50
51```console
52$ interop_augment_subcommands
53? failed
54error: A subcommand is required but one was not provided.
55```
56
57```console
58$ interop_augment_subcommands derived
59Derived subcommands: Derived {
60    derived_flag: false,
61}
62
63```
64
65```console
66$ interop_augment_subcommands derived --derived-flag
67Derived subcommands: Derived {
68    derived_flag: true,
69}
70
71```
72
73```console
74$ interop_augment_subcommands derived --unknown
75? failed
76error: Found argument '--unknown' which wasn't expected, or isn't valid in this context
77
78	If you tried to supply `--unknown` as a value rather than a flag, use `-- --unknown`
79
80USAGE:
81    interop_augment_subcommands[EXE] derived [OPTIONS]
82
83For more information try --help
84
85```
86
87```console
88$ interop_augment_subcommands unknown
89? failed
90error: Found argument 'unknown' which wasn't expected, or isn't valid in this context
91
92USAGE:
93    interop_augment_subcommands[EXE] [SUBCOMMAND]
94
95For more information try --help
96
97```
98
99## Hand-Implemented Subcommand
100
101```console
102$ interop_hand_subcommand
103? failed
104error: 'interop_hand_subcommand[EXE]' requires a subcommand but one was not provided
105
106USAGE:
107    interop_hand_subcommand[EXE] [OPTIONS] <SUBCOMMAND>
108
109For more information try --help
110
111```
112
113```console
114$ interop_hand_subcommand add
115Cli {
116    top_level: false,
117    subcommand: Add(
118        AddArgs {
119            name: [],
120        },
121    ),
122}
123
124```
125
126```console
127$ interop_hand_subcommand add a b c
128Cli {
129    top_level: false,
130    subcommand: Add(
131        AddArgs {
132            name: [
133                "a",
134                "b",
135                "c",
136            ],
137        },
138    ),
139}
140
141```
142
143```console
144$ interop_hand_subcommand add --unknown
145? failed
146error: Found argument '--unknown' which wasn't expected, or isn't valid in this context
147
148	If you tried to supply `--unknown` as a value rather than a flag, use `-- --unknown`
149
150USAGE:
151    interop_hand_subcommand[EXE] add [NAME]...
152
153For more information try --help
154
155```
156
157```console
158$ interop_hand_subcommand remove
159Cli {
160    top_level: false,
161    subcommand: Remove(
162        RemoveArgs {
163            force: false,
164            name: [],
165        },
166    ),
167}
168
169```
170
171```console
172$ interop_hand_subcommand remove --force a b c
173Cli {
174    top_level: false,
175    subcommand: Remove(
176        RemoveArgs {
177            force: true,
178            name: [
179                "a",
180                "b",
181                "c",
182            ],
183        },
184    ),
185}
186
187```
188
189```console
190$ interop_hand_subcommand unknown
191? failed
192error: Found argument 'unknown' which wasn't expected, or isn't valid in this context
193
194USAGE:
195    interop_hand_subcommand[EXE] [OPTIONS] <SUBCOMMAND>
196
197For more information try --help
198
199```
200
201## Flatten Hand-Implemented Args
202
203```console
204$ interop_flatten_hand_args
205Cli {
206    top_level: false,
207    more_args: CliArgs {
208        foo: false,
209        bar: false,
210        quuz: None,
211    },
212}
213
214```
215
216```console
217$ interop_flatten_hand_args -f --bar
218Cli {
219    top_level: false,
220    more_args: CliArgs {
221        foo: true,
222        bar: true,
223        quuz: None,
224    },
225}
226
227```
228
229```console
230$ interop_flatten_hand_args --quuz abc
231Cli {
232    top_level: false,
233    more_args: CliArgs {
234        foo: false,
235        bar: false,
236        quuz: Some(
237            "abc",
238        ),
239    },
240}
241
242```
243
244```console
245$ interop_flatten_hand_args --unknown
246? failed
247error: Found argument '--unknown' which wasn't expected, or isn't valid in this context
248
249	If you tried to supply `--unknown` as a value rather than a flag, use `-- --unknown`
250
251USAGE:
252    interop_flatten_hand_args[EXE] [OPTIONS]
253
254For more information try --help
255
256```
257