]> git.proxmox.com Git - rustc.git/blob - vendor/clap/examples/derive_ref/interop_tests.md
New upstream version 1.63.0+dfsg1
[rustc.git] / vendor / clap / examples / derive_ref / interop_tests.md
1 Following are tests for the interop examples in this directory.
2
3 ## Augment Args
4
5 ```console
6 $ interop_augment_args
7 Value of built: false
8 Value of derived via ArgMatches: false
9 Value of derived: DerivedArgs {
10 derived: false,
11 }
12
13 ```
14
15 ```console
16 $ interop_augment_args -b --derived
17 Value of built: true
18 Value of derived via ArgMatches: true
19 Value of derived: DerivedArgs {
20 derived: true,
21 }
22
23 ```
24
25 ```console
26 $ interop_augment_args -d --built
27 Value of built: true
28 Value of derived via ArgMatches: true
29 Value of derived: DerivedArgs {
30 derived: true,
31 }
32
33 ```
34
35 ```console
36 $ interop_augment_args --unknown
37 ? failed
38 error: 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
42 USAGE:
43 interop_augment_args[EXE] [OPTIONS]
44
45 For more information try --help
46
47 ```
48
49 ## Augment Subcommands
50
51 ```console
52 $ interop_augment_subcommands
53 ? failed
54 error: A subcommand is required but one was not provided.
55 ```
56
57 ```console
58 $ interop_augment_subcommands derived
59 Derived subcommands: Derived {
60 derived_flag: false,
61 }
62
63 ```
64
65 ```console
66 $ interop_augment_subcommands derived --derived-flag
67 Derived subcommands: Derived {
68 derived_flag: true,
69 }
70
71 ```
72
73 ```console
74 $ interop_augment_subcommands derived --unknown
75 ? failed
76 error: 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
80 USAGE:
81 interop_augment_subcommands[EXE] derived [OPTIONS]
82
83 For more information try --help
84
85 ```
86
87 ```console
88 $ interop_augment_subcommands unknown
89 ? failed
90 error: Found argument 'unknown' which wasn't expected, or isn't valid in this context
91
92 USAGE:
93 interop_augment_subcommands[EXE] [SUBCOMMAND]
94
95 For more information try --help
96
97 ```
98
99 ## Hand-Implemented Subcommand
100
101 ```console
102 $ interop_hand_subcommand
103 ? failed
104 error: 'interop_hand_subcommand[EXE]' requires a subcommand but one was not provided
105
106 USAGE:
107 interop_hand_subcommand[EXE] [OPTIONS] <SUBCOMMAND>
108
109 For more information try --help
110
111 ```
112
113 ```console
114 $ interop_hand_subcommand add
115 Cli {
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
128 Cli {
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
146 error: 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
150 USAGE:
151 interop_hand_subcommand[EXE] add [NAME]...
152
153 For more information try --help
154
155 ```
156
157 ```console
158 $ interop_hand_subcommand remove
159 Cli {
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
173 Cli {
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
192 error: Found argument 'unknown' which wasn't expected, or isn't valid in this context
193
194 USAGE:
195 interop_hand_subcommand[EXE] [OPTIONS] <SUBCOMMAND>
196
197 For more information try --help
198
199 ```
200
201 ## Flatten Hand-Implemented Args
202
203 ```console
204 $ interop_flatten_hand_args
205 Cli {
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
218 Cli {
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
231 Cli {
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
247 error: 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
251 USAGE:
252 interop_flatten_hand_args[EXE] [OPTIONS]
253
254 For more information try --help
255
256 ```