1 #![allow(deprecated)]
2 
3 // Std
4 use std::ops::BitOr;
5 #[cfg(feature = "yaml")]
6 use std::str::FromStr;
7 
8 #[allow(unused)]
9 use crate::Arg;
10 #[allow(unused)]
11 use crate::Command;
12 
13 // Third party
14 use bitflags::bitflags;
15 
16 #[doc(hidden)]
17 #[derive(Debug, Copy, Clone, PartialEq, Eq)]
18 pub struct AppFlags(Flags);
19 
20 impl Default for AppFlags {
default() -> Self21     fn default() -> Self {
22         AppFlags(Flags::COLOR_AUTO)
23     }
24 }
25 
26 /// Application level settings, which affect how [`Command`] operates
27 ///
28 /// **NOTE:** When these settings are used, they apply only to current command, and are *not*
29 /// propagated down or up through child or parent subcommands
30 ///
31 /// [`Command`]: crate::Command
32 #[derive(Debug, PartialEq, Copy, Clone)]
33 #[non_exhaustive]
34 pub enum AppSettings {
35     /// Deprecated, replaced with [`Command::ignore_errors`]
36     ///
37     /// Derive: replace `#[clap(setting = IgnoreErrors)]` with `#[clap(ignore_errors = true)]`
38     ///
39     /// Builder: replace `cmd.setting(IgnoreErrors)` with `cmd.ignore_errors = true`
40     #[cfg_attr(
41         feature = "deprecated",
42         deprecated(
43             since = "3.1.0",
44             note = "Replaced with `Command::ignore_errors`
45 
46 Derive: replace `#[clap(setting = IgnoreErrors)]` with `#[clap(ignore_errors = true)]`
47 
48 Builder: replace `cmd.setting(IgnoreErrors)` with `cmd.ignore_errors(true)`
49 "
50         )
51     )]
52     IgnoreErrors,
53 
54     /// Deprecated, replace
55     /// ```rust,no_run
56     /// let cmd = clap::Command::new("cmd")
57     ///     .global_setting(clap::AppSettings::WaitOnError)
58     ///     .arg(clap::arg!(--flag));
59     /// let m = cmd.get_matches();
60     /// ```
61     /// with
62     /// ```rust
63     /// let cmd = clap::Command::new("cmd")
64     ///     .arg(clap::arg!(--flag));
65     /// let m = match cmd.try_get_matches() {
66     ///     Ok(m) => m,
67     ///     Err(err) => {
68     ///         if err.use_stderr() {
69     ///             let _ = err.print();
70     ///
71     ///             eprintln!("\nPress [ENTER] / [RETURN] to continue...");
72     ///             use std::io::BufRead;
73     ///             let mut s = String::new();
74     ///             let i = std::io::stdin();
75     ///             i.lock().read_line(&mut s).unwrap();
76     ///
77     ///             std::process::exit(2);
78     ///         } else {
79     ///             let _ = err.print();
80     ///             std::process::exit(0);
81     ///         }
82     ///     }
83     /// };
84     /// ```
85     #[cfg_attr(
86         feature = "deprecated",
87         deprecated(
88             since = "3.1.0",
89             note = "See documentation for how to hand-implement this"
90         )
91     )]
92     WaitOnError,
93 
94     /// Deprecated, replaced with [`Command::allow_hyphen_values`] and
95     /// [`Arg::is_allow_hyphen_values_set`]
96     ///
97     /// Derive: replace `#[clap(setting = AllowHyphenValues)]` with `#[clap(allow_hyphen_values = true)]`
98     ///
99     /// Builder: replace `cmd.setting(AllowHyphenValues)` with `cmd.allow_hyphen_values(true)`
100     #[cfg_attr(
101         feature = "deprecated",
102         deprecated(
103             since = "3.1.0",
104             note = "Replaced with `Command::allow_hyphen_values` and `Arg::is_allow_hyphen_values_set`
105 
106 Derive: replace `#[clap(setting = AllowHyphenValues)]` with `#[clap(allow_hyphen_values = true)]`
107 
108 Builder: replace `cmd.setting(AllowHyphenValues)` with `cmd.allow_hyphen_values(true)`
109 "
110         )
111     )]
112     AllowHyphenValues,
113 
114     /// Deprecated, replaced with [`Command::allow_negative_numbers`] and
115     /// [`Command::is_allow_negative_numbers_set`]
116     ///
117     /// Derive: replace `#[clap(setting = AllowNegativeNumbers)]` with `#[clap(allow_negative_numbers = true)]`
118     ///
119     /// Builder: replace `cmd.setting(AllowNegativeNumbers)` with `cmd.allow_negative_numbers(true)`
120     #[cfg_attr(
121         feature = "deprecated",
122         deprecated(
123             since = "3.1.0",
124             note = "Replaced with `Command::allow_negative_numbers` and `Command::is_allow_negative_numbers_set`
125 
126 Derive: replace `#[clap(setting = AllowNegativeNumbers)]` with `#[clap(allow_negative_numbers = true)]`
127 
128 Builder: replace `cmd.setting(AllowNegativeNumbers)` with `cmd.allow_negative_numbers(true)`
129 "
130         )
131     )]
132     AllowNegativeNumbers,
133 
134     /// Deprecated, replaced with [`ArgAction::Set`][super::ArgAction::Set]
135     ///
136     /// The new actions (`ArgAction::Set`, `ArgAction::SetTrue`) do this by default.
137     ///
138     /// See `ArgAction::StoreValue` and `ArgAction::IncOccurrence` for how to migrate
139     #[cfg_attr(
140         feature = "deprecated",
141         deprecated(
142             since = "3.2.0",
143             note = "Replaced with `Arg::action(ArgAction::...)`
144 
145 The new actions (`ArgAction::Set`, `ArgAction::SetTrue`) do this by default.
146 
147 See `ArgAction::StoreValue` and `ArgAction::IncOccurrence` for how to migrate
148 "
149         )
150     )]
151     AllArgsOverrideSelf,
152 
153     /// Deprecated, replaced with [`Command::allow_missing_positional`] and
154     /// [`Command::is_allow_missing_positional_set`]
155     ///
156     /// Derive: replace `#[clap(setting = AllowMissingPositional)]` with `#[clap(allow_missing_positional = true)]`
157     ///
158     /// Builder: replace `cmd.setting(AllowMissingPositional)` with `cmd.allow_missing_positional(true)`
159     #[cfg_attr(
160         feature = "deprecated",
161         deprecated(
162             since = "3.1.0",
163             note = "Replaced with `Command::allow_missing_positional` and `Command::is_allow_missing_positional_set`
164 
165 Derive: replace `#[clap(setting = AllowMissingPositional)]` with `#[clap(allow_missing_positional = true)]`
166 
167 Builder: replace `cmd.setting(AllowMissingPositional)` with `cmd.allow_missing_positional(true)`
168 "
169         )
170     )]
171     AllowMissingPositional,
172 
173     /// Deprecated, replaced with [`Command::trailing_var_arg`] and [`Command::is_trailing_var_arg_set`]
174     ///
175     /// Derive: replace `#[clap(setting = TrailingVarArg)]` with `#[clap(trailing_var_arg = true)]`
176     ///
177     /// Builder: replace `cmd.setting(TrailingVarArg)` with `cmd.trailing_var_arg(true)`
178     #[cfg_attr(
179         feature = "deprecated",
180         deprecated(
181             since = "3.1.0",
182             note = "Replaced with `Command::trailing_var_arg` and `Command::is_trailing_var_arg_set`
183 
184 Derive: replace `#[clap(setting = TrailingVarArg)]` with `#[clap(trailing_var_arg = true)]`
185 
186 Builder: replace `cmd.setting(TrailingVarArg)` with `cmd.trailing_var_arg(true)`
187 "
188         )
189     )]
190     TrailingVarArg,
191 
192     /// Deprecated, replaced with [`Command::dont_delimit_trailing_values`] and
193     /// [`Command::is_dont_delimit_trailing_values_set`]
194     ///
195     /// Derive: replace `#[clap(setting = DontDelimitTrailingValues)]` with `#[clap(dont_delimit_trailing_values = true)]`
196     ///
197     /// Builder: replace `cmd.setting(DontDelimitTrailingValues)` with `cmd.dont_delimit_trailing_values(true)`
198     #[cfg_attr(
199         feature = "deprecated",
200         deprecated(
201             since = "3.1.0",
202             note = "Replaced with `Command::dont_delimit_trailing_values` and `Command::is_dont_delimit_trailing_values_set`
203 
204 Derive: replace `#[clap(setting = DontDelimitTrailingValues)]` with `#[clap(dont_delimit_trailing_values = true)]`
205 
206 Builder: replace `cmd.setting(DontDelimitTrailingValues)` with `cmd.dont_delimit_trailing_values(true)`
207 "
208         )
209     )]
210     DontDelimitTrailingValues,
211 
212     /// Deprecated, replaced with [`Command::infer_long_args`]
213     ///
214     /// Derive: replace `#[clap(setting = InferLongArgs)]` with `#[clap(infer_long_args = true)]`
215     ///
216     /// Builder: replace `cmd.setting(InferLongArgs)` with `cmd.infer_long_args(true)`
217     #[cfg_attr(
218         feature = "deprecated",
219         deprecated(
220             since = "3.1.0",
221             note = "Replaced with `Command::infer_long_args`
222 
223 Derive: replace `#[clap(setting = InferLongArgs)]` with `#[clap(infer_long_args = true)]`
224 
225 Builder: replace `cmd.setting(InferLongArgs)` with `cmd.infer_long_args(true)`
226 "
227         )
228     )]
229     InferLongArgs,
230 
231     /// Deprecated, replaced with [`Command::infer_subcommands`]
232     ///
233     /// Derive: replace `#[clap(setting = InferSubcommands)]` with `#[clap(infer_subcommands = true)]`
234     ///
235     /// Builder: replace `cmd.setting(InferSubcommands)` with `cmd.infer_subcommands(true)`
236     #[cfg_attr(
237         feature = "deprecated",
238         deprecated(
239             since = "3.1.0",
240             note = "Replaced with `Command::infer_subcommands`
241 
242 Derive: replace `#[clap(setting = InferSubcommands)]` with `#[clap(infer_subcommands = true)]`
243 
244 Builder: replace `cmd.setting(InferSubcommands)` with `cmd.infer_subcommands(true)`
245 "
246         )
247     )]
248     InferSubcommands,
249 
250     /// Deprecated, replaced with [`Command::subcommand_required`] and
251     /// [`Command::is_subcommand_required_set`]
252     ///
253     /// Derive: replace `#[clap(setting = SubcommandRequired)]` with `#[clap(subcommand_required = true)]`
254     ///
255     /// Builder: replace `cmd.setting(SubcommandRequired)` with `cmd.subcommand_required(true)`
256     #[cfg_attr(
257         feature = "deprecated",
258         deprecated(
259             since = "3.1.0",
260             note = "Replaced with `Command::subcommand_required` and `Command::is_subcommand_required_set`
261 
262 Derive: replace `#[clap(setting = SubcommandRequired)]` with `#[clap(subcommand_required = true)]`
263 
264 Builder: replace `cmd.setting(SubcommandRequired)` with `cmd.subcommand_required(true)`
265 "
266         )
267     )]
268     SubcommandRequired,
269 
270     /// Deprecated, replaced with [`Command::subcommand_required`] combined with
271     /// [`Command::arg_required_else_help`].
272     ///
273     /// Derive: replace `#[clap(setting = SubcommandRequiredElseHelp)]` with `#[clap(subcommand_required = true, arg_required_else_help = true)]`
274     ///
275     /// Builder: replace `cmd.setting(SubcommandRequiredElseHelp)` with `cmd.subcommand_required(true).arg_required_else_help(true)`
276     #[cfg_attr(
277         feature = "deprecated",
278         deprecated(
279             since = "3.1.0",
280             note = "Replaced with `Command::subcommand_required` combined with `Command::arg_required_else_help`
281 
282 Derive: replace `#[clap(setting = SubcommandRequiredElseHelp)]` with `#[clap(subcommand_required = true, arg_required_else_help = true)]`
283 
284 Builder: replace `cmd.setting(SubcommandRequiredElseHelp)` with `cmd.subcommand_required(true).arg_required_else_help(true)`
285 "
286         )
287     )]
288     SubcommandRequiredElseHelp,
289 
290     /// Deprecated, replaced with [`Command::allow_external_subcommands`] and
291     /// [`Command::is_allow_external_subcommands_set`]
292     ///
293     /// Derive: replace `#[clap(setting = AllowExternalSubcommands)]` with `#[clap(allow_external_subcommands = true)]`
294     ///
295     /// Builder: replace `cmd.setting(AllowExternalSubcommands)` with `cmd.allow_external_subcommands(true)`
296     #[cfg_attr(
297         feature = "deprecated",
298         deprecated(
299             since = "3.1.0",
300             note = "Replaced with `Command::allow_external_subcommands` and `Command::is_allow_external_subcommands_set`
301 
302 Derive: replace `#[clap(setting = AllowExternalSubcommands)]` with `#[clap(allow_external_subcommands = true)]`
303 
304 Builder: replace `cmd.setting(AllowExternalSubcommands)` with `cmd.allow_external_subcommands(true)`
305 "
306         )
307     )]
308     AllowExternalSubcommands,
309 
310     /// Deprecated, replaced with [`Command::multicall`] and [`Command::is_multicall_set`]
311     ///
312     /// Derive: replace `#[clap(setting = Multicall)]` with `#[clap(multicall = true)]`
313     ///
314     /// Builder: replace `cmd.setting(Multicall)` with `cmd.multicall(true)`
315     #[cfg_attr(
316         feature = "deprecated",
317         deprecated(
318             since = "3.1.0",
319             note = "Replaced with `Command::multicall` and `Command::is_multicall_set`
320 
321 Derive: replace `#[clap(setting = Multicall)]` with `#[clap(multicall = true)]`
322 
323 Builder: replace `cmd.setting(Multicall)` with `cmd.multicall(true)`
324 "
325         )
326     )]
327     Multicall,
328 
329     /// Deprecated, replaced with [`Command::allow_invalid_utf8_for_external_subcommands`] and [`Command::is_allow_invalid_utf8_for_external_subcommands_set`]
330     ///
331     /// Derive: replace `#[clap(setting = AllowInvalidUtf8ForExternalSubcommands)]` with `#[clap(allow_invalid_utf8_for_external_subcommands = true)]`
332     ///
333     /// Builder: replace `cmd.setting(AllowInvalidUtf8ForExternalSubcommands)` with `cmd.allow_invalid_utf8_for_external_subcommands(true)`
334     #[cfg_attr(
335         feature = "deprecated",
336         deprecated(
337             since = "3.1.0",
338             note = "Replaced with `Command::allow_invalid_utf8_for_external_subcommands` and `Command::is_allow_invalid_utf8_for_external_subcommands_set`
339 
340 Derive: replace `#[clap(setting = AllowInvalidUtf8ForExternalSubcommands)]` with `#[clap(allow_invalid_utf8_for_external_subcommands = true)]`
341 
342 Builder: replace `cmd.setting(AllowInvalidUtf8ForExternalSubcommands)` with `cmd.allow_invalid_utf8_for_external_subcommands(true)`
343 "
344         )
345     )]
346     AllowInvalidUtf8ForExternalSubcommands,
347 
348     /// Deprecated, this is now the default
349     ///
350     /// Derive: remove `#[clap(setting = UseLongFormatForHelpSubcommand)]`
351     ///
352     /// Builder: remove `cmd.setting(UseLongFormatForHelpSubcommand)`
353     #[cfg_attr(
354         feature = "deprecated",
355         deprecated(
356             since = "3.1.0",
357             note = "This is now the default
358 
359 Derive: remove `#[clap(setting = UseLongFormatForHelpSubcommand)]`
360 
361 Builder: remove `cmd.setting(UseLongFormatForHelpSubcommand)`
362 "
363         )
364     )]
365     UseLongFormatForHelpSubcommand,
366 
367     /// Deprecated, replaced with [`Command::subcommand_negates_reqs`] and
368     /// [`Command::is_subcommand_negates_reqs_set`]
369     ///
370     /// Derive: replace `#[clap(setting = SubcommandsNegateReqs)]` with `#[clap(subcommand_negates_reqs = true)]`
371     ///
372     /// Builder: replace `cmd.setting(SubcommandsNegateReqs)` with `cmd.subcommand_negates_reqs(true)`
373     #[cfg_attr(
374         feature = "deprecated",
375         deprecated(
376             since = "3.1.0",
377             note = "Replaced with `Command::subcommand_negates_reqs` and `Command::is_subcommand_negates_reqs_set`
378 
379 Derive: replace `#[clap(setting = SubcommandsNegateReqs)]` with `#[clap(subcommand_negates_reqs = true)]`
380 
381 Builder: replace `cmd.setting(SubcommandsNegateReqs)` with `cmd.subcommand_negates_reqs(true)`
382 "
383         )
384     )]
385     SubcommandsNegateReqs,
386 
387     /// Deprecated, replaced with [`Command::args_conflicts_with_subcommands`] and
388     /// [`Command::is_args_conflicts_with_subcommands_set`]
389     ///
390     /// Derive: replace `#[clap(setting = ArgsNegateSubcommands)]` with `#[clap(args_conflicts_with_subcommands = true)]`
391     ///
392     /// Builder: replace `cmd.setting(ArgsNegateSubcommands)` with `cmd.args_conflicts_with_subcommands(true)`
393     #[cfg_attr(
394         feature = "deprecated",
395         deprecated(
396             since = "3.1.0",
397             note = "Replaced with `Command::args_conflicts_with_subcommands` and `Command::is_args_conflicts_with_subcommands_set`
398 
399 Derive: replace `#[clap(setting = ArgsNegateSubcommands)]` with `#[clap(args_conflicts_with_subcommands = true)]`
400 
401 Builder: replace `cmd.setting(ArgsNegateSubcommands)` with `cmd.args_conflicts_with_subcommands(true)`
402 "
403         )
404     )]
405     ArgsNegateSubcommands,
406 
407     /// Deprecated, replaced with [`Command::subcommand_precedence_over_arg`] and
408     /// [`Command::is_subcommand_precedence_over_arg_set`]
409     ///
410     /// Derive: replace `#[clap(setting = SubcommandPrecedenceOverArg)]` with `#[clap(subcommand_precedence_over_arg = true)]`
411     ///
412     /// Builder: replace `cmd.setting(SubcommandPrecedenceOverArg)` with `cmd.subcommand_precedence_over_arg(true)`
413     #[cfg_attr(
414         feature = "deprecated",
415         deprecated(
416             since = "3.1.0",
417             note = "Replaced with `Command::subcommand_precedence_over_arg` and `Command::is_subcommand_precedence_over_arg_set`
418 
419 Derive: replace `#[clap(setting = SubcommandPrecedenceOverArg)]` with `#[clap(subcommand_precedence_over_arg = true)]`
420 
421 Builder: replace `cmd.setting(SubcommandPrecedenceOverArg)` with `cmd.subcommand_precedence_over_arg(true)`
422 "
423         )
424     )]
425     SubcommandPrecedenceOverArg,
426 
427     /// Deprecated, replaced with [`Command::arg_required_else_help`] and
428     /// [`Command::is_arg_required_else_help_set`]
429     ///
430     /// Derive: replace `#[clap(setting = ArgRequiredElseHelp)]` with `#[clap(arg_required_else_help = true)]`
431     ///
432     /// Builder: replace `cmd.setting(ArgRequiredElseHelp)` with `cmd.arg_required_else_help(true)`
433     #[cfg_attr(
434         feature = "deprecated",
435         deprecated(
436             since = "3.1.0",
437             note = "Replaced with `Command::arg_required_else_help` and `Command::is_arg_required_else_help_set`
438 
439 Derive: replace `#[clap(setting = ArgRequiredElseHelp)]` with `#[clap(arg_required_else_help = true)]`
440 
441 Builder: replace `cmd.setting(ArgRequiredElseHelp)` with `cmd.arg_required_else_help(true)`
442 "
443         )
444     )]
445     ArgRequiredElseHelp,
446 
447     /// Displays the arguments and [`subcommands`] in the help message in the order that they were
448     /// declared in, and not alphabetically which is the default.
449     ///
450     /// To override the declaration order, see [`Arg::display_order`] and [`Command::display_order`].
451     ///
452     /// # Examples
453     ///
454     /// ```no_run
455     /// # use clap::{Command, Arg, AppSettings};
456     /// Command::new("myprog")
457     ///     .global_setting(AppSettings::DeriveDisplayOrder)
458     ///     .get_matches();
459     /// ```
460     ///
461     /// [`subcommands`]: crate::Command::subcommand()
462     /// [`Arg::display_order`]: crate::Arg::display_order
463     /// [`Command::display_order`]: crate::Command::display_order
464     DeriveDisplayOrder,
465 
466     /// Deprecated, replaced with [`Command::dont_collapse_args_in_usage`] and
467     /// [`Command::is_dont_collapse_args_in_usage_set`]
468     ///
469     /// Derive: replace `#[clap(setting = DontCollapseArgsInUsage)]` with `#[clap(dont_collapse_args_in_usage = true)]`
470     ///
471     /// Builder: replace `cmd.setting(DontCollapseArgsInUsage)` with `cmd.dont_collapse_args_in_usage(true)`
472     #[cfg_attr(
473         feature = "deprecated",
474         deprecated(
475             since = "3.1.0",
476             note = "Replaced with `Command::dont_collapse_args_in_usage` and `Command::is_dont_collapse_args_in_usage_set`
477 
478 Derive: replace `#[clap(setting = DontCollapseArgsInUsage)]` with `#[clap(dont_collapse_args_in_usage = true)]`
479 
480 Builder: replace `cmd.setting(DontCollapseArgsInUsage)` with `cmd.dont_collapse_args_in_usage(true)`
481 "
482         )
483     )]
484     DontCollapseArgsInUsage,
485 
486     /// Deprecated, replaced with [`Command::next_line_help`] and [`Command::is_next_line_help_set`]
487     ///
488     /// Derive: replace `#[clap(setting = NextLineHelp)]` with `#[clap(next_line_help = true)]`
489     ///
490     /// Builder: replace `cmd.setting(NextLineHelp)` with `cmd.next_line_help(true)`
491     #[cfg_attr(
492         feature = "deprecated",
493         deprecated(
494             since = "3.1.0",
495             note = "Replaced with `Command::next_line_help` and `Command::is_next_line_help_set`
496 
497 Derive: replace `#[clap(setting = NextLineHelp)]` with `#[clap(next_line_help = true)]`
498 
499 Builder: replace `cmd.setting(NextLineHelp)` with `cmd.next_line_help(true)`
500 "
501         )
502     )]
503     NextLineHelp,
504 
505     /// Deprecated, replaced with [`Command::disable_colored_help`] and
506     /// [`Command::is_disable_colored_help_set`]
507     ///
508     /// Derive: replace `#[clap(setting = DisableColoredHelp)]` with `#[clap(disable_colored_help = true)]`
509     ///
510     /// Builder: replace `cmd.setting(DisableColoredHelp)` with `cmd.disable_colored_help(true)`
511     #[cfg_attr(
512         feature = "deprecated",
513         deprecated(
514             since = "3.1.0",
515             note = "Replaced with `Command::disable_colored_help` and `Command::is_disable_colored_help_set`
516 
517 Derive: replace `#[clap(setting = DisableColoredHelp)]` with `#[clap(disable_colored_help = true)]`
518 
519 Builder: replace `cmd.setting(DisableColoredHelp)` with `cmd.disable_colored_help(true)`
520 "
521         )
522     )]
523     DisableColoredHelp,
524 
525     /// Deprecated, replaced with [`Command::disable_help_flag`] and [`Command::is_disable_help_flag_set`]
526     ///
527     /// Derive: replace `#[clap(setting = DisableHelpFlag)]` with `#[clap(disable_help_flag = true)]`
528     ///
529     /// Builder: replace `cmd.setting(DisableHelpFlag)` with `cmd.disable_help_flag(true)`
530     #[cfg_attr(
531         feature = "deprecated",
532         deprecated(
533             since = "3.1.0",
534             note = "Replaced with `Command::disable_help_flag` and `Command::is_disable_help_flag_set`
535 
536 Derive: replace `#[clap(setting = DisableHelpFlag)]` with `#[clap(disable_help_flag = true)]`
537 
538 Builder: replace `cmd.setting(DisableHelpFlag)` with `cmd.disable_help_flag(true)`
539 "
540         )
541     )]
542     DisableHelpFlag,
543 
544     /// Deprecated, replaced with [`Command::disable_help_subcommand`] and
545     /// [`Command::is_disable_help_subcommand_set`]
546     ///
547     /// Derive: replace `#[clap(setting = DisableHelpSubcommand)]` with `#[clap(disable_help_subcommand = true)]`
548     ///
549     /// Builder: replace `cmd.setting(DisableHelpSubcommand)` with `cmd.disable_help_subcommand(true)`
550     #[cfg_attr(
551         feature = "deprecated",
552         deprecated(
553             since = "3.1.0",
554             note = "Replaced with `Command::disable_help_subcommand` and `Command::is_disable_help_subcommand_set`
555 
556 Derive: replace `#[clap(setting = DisableHelpSubcommand)]` with `#[clap(disable_help_subcommand = true)]`
557 
558 Builder: replace `cmd.setting(DisableHelpSubcommand)` with `cmd.disable_help_subcommand(true)`
559 "
560         )
561     )]
562     DisableHelpSubcommand,
563 
564     /// Deprecated, replaced with [`Command::disable_version_flag`] and
565     /// [`Command::is_disable_version_flag_set`]
566     ///
567     /// Derive: replace `#[clap(setting = DisableVersionFlag)]` with `#[clap(disable_version_flag = true)]`
568     ///
569     /// Builder: replace `cmd.setting(DisableVersionFlag)` with `cmd.disable_version_flag(true)`
570     #[cfg_attr(
571         feature = "deprecated",
572         deprecated(
573             since = "3.1.0",
574             note = "Replaced with `Command::disable_version_flag` and `Command::is_disable_version_flag_set`
575 
576 Derive: replace `#[clap(setting = DisableVersionFlag)]` with `#[clap(disable_version_flag = true)]`
577 
578 Builder: replace `cmd.setting(DisableVersionFlag)` with `cmd.disable_version_flag(true)`
579 "
580         )
581     )]
582     DisableVersionFlag,
583 
584     /// Deprecated, replaced with [`Command::propagate_version`] and [`Command::is_propagate_version_set`]
585     ///
586     /// Derive: replace `#[clap(setting = PropagateVersion)]` with `#[clap(propagate_version = true)]`
587     ///
588     /// Builder: replace `cmd.setting(PropagateVersion)` with `cmd.propagate_version(true)`
589     #[cfg_attr(
590         feature = "deprecated",
591         deprecated(
592             since = "3.1.0",
593             note = "Replaced with `Command::propagate_version` and `Command::is_propagate_version_set`
594 
595 Derive: replace `#[clap(setting = PropagateVersion)]` with `#[clap(propagate_version = true)]`
596 
597 Builder: replace `cmd.setting(PropagateVersion)` with `cmd.propagate_version(true)`
598 "
599         )
600     )]
601     PropagateVersion,
602 
603     /// Deprecated, replaced with [`Command::hide`] and [`Command::is_hide_set`]
604     ///
605     /// Derive: replace `#[clap(setting = Hidden)]` with `#[clap(hide = true)]`
606     ///
607     /// Builder: replace `cmd.setting(Hidden)` with `cmd.hide(true)`
608     #[cfg_attr(
609         feature = "deprecated",
610         deprecated(
611             since = "3.1.0",
612             note = "Replaced with `Command::hide` and `Command::is_hide_set`
613 
614 Derive: replace `#[clap(setting = Hidden)]` with `#[clap(hide = true)]`
615 
616 Builder: replace `cmd.setting(Hidden)` with `cmd.hide(true)`
617 "
618         )
619     )]
620     Hidden,
621 
622     /// Deprecated, replaced with [`Command::hide_possible_values`] and
623     /// [`Arg::is_hide_possible_values_set`]
624     ///
625     /// Derive: replace `#[clap(setting = HidePossibleValues)]` with `#[clap(hide_possible_values = true)]`
626     ///
627     /// Builder: replace `cmd.setting(HidePossibleValues)` with `cmd.hide_possible_values(true)`
628     #[cfg_attr(
629         feature = "deprecated",
630         deprecated(
631             since = "3.1.0",
632             note = "Replaced with `Command::hide_possible_values` and `Arg::is_hide_possible_values_set`
633 
634 Derive: replace `#[clap(setting = HidePossibleValues)]` with `#[clap(hide_possible_values = true)]`
635 
636 Builder: replace `cmd.setting(HidePossibleValues)` with `cmd.hide_possible_values(true)`
637 "
638         )
639     )]
640     HidePossibleValues,
641 
642     /// Deprecated, replaced with [`Command::help_expected`]
643     ///
644     /// Derive: replace `#[clap(setting = HelpExpected)]` with `#[clap(help_expected = true)]`
645     ///
646     /// Builder: replace `cmd.setting(HelpExpected)` with `cmd.help_expected(true)`
647     #[cfg_attr(
648         feature = "deprecated",
649         deprecated(
650             since = "3.1.0",
651             note = "Replaced with `Command::help_expected`
652 
653 Derive: replace `#[clap(setting = HelpExpected)]` with `#[clap(help_expected = true)]`
654 
655 Builder: replace `cmd.setting(HelpExpected)` with `cmd.help_expected(true)`
656 "
657         )
658     )]
659     HelpExpected,
660 
661     /// Deprecated, replaced with [`Command::no_binary_name`]
662     ///
663     /// Derive: replace `#[clap(setting = NoBinaryName)]` with `#[clap(no_binary_name = true)]`
664     ///
665     /// Builder: replace `cmd.setting(NoBinaryName)` with `cmd.no_binary_name(true)`
666     #[cfg_attr(
667         feature = "deprecated",
668         deprecated(
669             since = "3.1.0",
670             note = "Replaced with `Command::no_binary_name`
671 
672 Derive: replace `#[clap(setting = NoBinaryName)]` with `#[clap(no_binary_name = true)]`
673 
674 Builder: replace `cmd.setting(NoBinaryName)` with `cmd.no_binary_name(true)`
675 "
676         )
677     )]
678     NoBinaryName,
679 
680     /// Deprecated, replaced with [`Arg::action`][super::Arg::action]
681     ///
682     /// Derive: replace `#[clap(setting = NoAutoHelp)]` with setting an explicit action on your help argument
683     ///
684     /// Builder: replace `cmd.setting(NoAutoHelp)` with setting an explicit action on your help argument
685     #[cfg_attr(
686         feature = "deprecated",
687         deprecated(
688             since = "3.2.0",
689             note = "Replaced with `Arg::action`
690 
691 Derive: replace `#[clap(setting = NoAutoHelp)]` with setting an explicit action on your help argument
692 
693 Builder: replace `cmd.setting(NoAutoHelp)` with setting an explicit action on your help argument
694 "
695         )
696     )]
697     NoAutoHelp,
698 
699     /// Deprecated, replaced with [`Arg::action`][super::Arg::action]
700     ///
701     /// Derive: replace `#[clap(setting = NoAutoVersion)]` with setting an explicit action on your version argument
702     ///
703     /// Builder: replace `cmd.setting(NoAutoVersion)` with setting an explicit action on your version argument
704     #[cfg_attr(
705         feature = "deprecated",
706         deprecated(
707             since = "3.2.0",
708             note = "Replaced with `Arg::action`
709 
710 Derive: replace `#[clap(setting = NoAutoVersion)]` with setting an explicit action on your version argument
711 
712 Builder: replace `cmd.setting(NoAutoVersion)` with setting an explicit action on your version argument
713 "
714         )
715     )]
716     NoAutoVersion,
717 
718     /// Deprecated, replaced with [`Command::allow_hyphen_values`]
719     ///
720     /// Derive: replace `#[clap(setting = AllowLeadingHyphen)]` with `#[clap(allow_hyphen_values = true)]`
721     ///
722     /// Builder: replace `cmd.setting(AllowLeadingHyphen)` with `cmd.allow_hyphen_values(true)`
723     #[cfg_attr(
724         feature = "deprecated",
725         deprecated(
726             since = "3.0.0",
727             note = "Replaced with `Command::allow_hyphen_values`
728 
729 Derive: replace `#[clap(setting = AllowLeadingHyphen)]` with `#[clap(allow_hyphen_values = true)]`
730 
731 Builder: replace `cmd.setting(AllowLeadingHyphen)` with `cmd.allow_hyphen_values(true)`
732 "
733         )
734     )]
735     #[doc(hidden)]
736     AllowLeadingHyphen,
737 
738     /// Deprecated, replaced with [`Command::allow_invalid_utf8_for_external_subcommands`] and [`Command::is_allow_invalid_utf8_for_external_subcommands_set`]
739     ///
740     /// Derive: replace `#[clap(setting = StrictUtf8)]` with `#[clap(allow_invalid_utf8_for_external_subcommands = true)]`
741     ///
742     /// Builder: replace `cmd.setting(StrictUtf8)` with `cmd.allow_invalid_utf8_for_external_subcommands(true)`
743     #[cfg_attr(
744         feature = "deprecated",
745         deprecated(
746             since = "3.0.0",
747             note = "Replaced with `Command::allow_invalid_utf8_for_external_subcommands` and `Command::is_allow_invalid_utf8_for_external_subcommands_set`
748 
749 Derive: replace `#[clap(setting = StrictUtf8)]` with `#[clap(allow_invalid_utf8_for_external_subcommands = true)]`
750 
751 Builder: replace `cmd.setting(StrictUtf8)` with `cmd.allow_invalid_utf8_for_external_subcommands(true)`
752 "
753         )
754     )]
755     #[doc(hidden)]
756     StrictUtf8,
757 
758     /// Deprecated, this is now the default
759     ///
760     /// Derive: remove `#[clap(setting = UnifiedHelpMessage)]`
761     ///
762     /// Builder: remove `cmd.setting(UnifiedHelpMessage)`
763     #[cfg_attr(
764         feature = "deprecated",
765         deprecated(
766             since = "3.0.0",
767             note = "This is now the default
768 
769 Derive: remove `#[clap(setting = UnifiedHelpMessage)]`
770 
771 Builder: remove `cmd.setting(UnifiedHelpMessage)`
772 "
773         )
774     )]
775     #[doc(hidden)]
776     UnifiedHelpMessage,
777 
778     /// Deprecated, this is now the default
779     ///
780     /// Derive: remove `#[clap(setting = ColoredHelp)]`
781     ///
782     /// Builder: remove `cmd.setting(ColoredHelp)`
783     #[cfg_attr(
784         feature = "deprecated",
785         deprecated(
786             since = "3.0.0",
787             note = "This is now the default
788 
789 Derive: remove `#[clap(setting = ColoredHelp)]`
790 
791 Builder: remove `cmd.setting(ColoredHelp)`
792 "
793         )
794     )]
795     #[doc(hidden)]
796     ColoredHelp,
797 
798     /// Deprecated, see [`Command::color`][crate::Command::color]
799     ///
800     /// Derive: replace `#[clap(setting = ColorAuto)]` with `#[clap(color = ColorChoice::Auto)]``
801     ///
802     /// Builder: replace `cmd.setting(ColorAuto)` with `cmd.color(Color::Auto)`
803     #[cfg_attr(
804         feature = "deprecated",
805         deprecated(
806             since = "3.0.0",
807             note = "Replaced with `Command::color`
808 
809 Derive: replace `#[clap(setting = ColorAuto)]` with `#[clap(color = ColorChoice::Auto)]``
810 
811 Builder: replace `cmd.setting(ColorAuto)` with `cmd.color(Color::Auto)`
812 "
813         )
814     )]
815     #[doc(hidden)]
816     ColorAuto,
817 
818     /// Deprecated, replaced with [`Command::color`][crate::Command::color]
819     ///
820     /// Derive: replace `#[clap(setting = ColorAlways)]` with `#[clap(color = ColorChoice::Always)]``
821     ///
822     /// Builder: replace `cmd.setting(ColorAlways)` with `cmd.color(Color::Always)`
823     #[cfg_attr(
824         feature = "deprecated",
825         deprecated(
826             since = "3.0.0",
827             note = "Replaced with `Command::color`
828 
829 Derive: replace `#[clap(setting = ColorAlways)]` with `#[clap(color = ColorChoice::Always)]``
830 
831 Builder: replace `cmd.setting(ColorAlways)` with `cmd.color(Color::Always)`
832 "
833         )
834     )]
835     #[doc(hidden)]
836     ColorAlways,
837 
838     /// Deprecated, replaced with [`Command::color`][crate::Command::color]
839     ///
840     /// Derive: replace `#[clap(setting = ColorNever)]` with `#[clap(color = ColorChoice::Never)]``
841     ///
842     /// Builder: replace `cmd.setting(ColorNever)` with `cmd.color(Color::Never)`
843     #[cfg_attr(
844         feature = "deprecated",
845         deprecated(
846             since = "3.0.0",
847             note = "Replaced with `Command::color`
848 
849 Derive: replace `#[clap(setting = ColorNever)]` with `#[clap(color = ColorChoice::Never)]``
850 
851 Builder: replace `cmd.setting(ColorNever)` with `cmd.color(Color::Never)`
852 "
853         )
854     )]
855     #[doc(hidden)]
856     ColorNever,
857 
858     /// Deprecated, replaced with [`Command::disable_help_flag`] and [`Command::is_disable_help_flag_set`]
859     ///
860     /// Derive: replace `#[clap(setting = DisableHelpFlags)]` with `#[clap(disable_help_flag = true)]`
861     ///
862     /// Builder: replace `cmd.setting(DisableHelpFlags)` with `cmd.disable_help_flag(true)`
863     #[cfg_attr(
864         feature = "deprecated",
865         deprecated(
866             since = "3.0.0",
867             note = "Replaced with `Command::disable_help_flag` and `Command::is_disable_help_flag_set`
868 
869 Derive: replace `#[clap(setting = DisableHelpFlags)]` with `#[clap(disable_help_flag = true)]`
870 
871 Builder: replace `cmd.setting(DisableHelpFlags)` with `cmd.disable_help_flag(true)`
872 "
873         )
874     )]
875     #[doc(hidden)]
876     DisableHelpFlags,
877 
878     /// Deprecated, replaced with [`Command::disable_version_flag`] and
879     /// [`Command::is_disable_version_flag_set`]
880     ///
881     /// Derive: replace `#[clap(setting = DisableVersion)]` with `#[clap(disable_version_flag = true)]`
882     ///
883     /// Builder: replace `cmd.setting(DisableVersion)` with `cmd.disable_version_flag(true)`
884     #[cfg_attr(
885         feature = "deprecated",
886         deprecated(
887             since = "3.0.0",
888             note = "Replaced with `Command::disable_version_flag` and `Command::is_disable_version_flag_set`
889 
890 Derive: replace `#[clap(setting = DisableVersion)]` with `#[clap(disable_version_flag = true)]`
891 
892 Builder: replace `cmd.setting(DisableVersion)` with `cmd.disable_version_flag(true)`
893 "
894         )
895     )]
896     #[doc(hidden)]
897     DisableVersion,
898 
899     /// Deprecated, replaced with [`Command::propagate_version`] and [`Command::is_propagate_version_set`]
900     ///
901     /// Derive: replace `#[clap(setting = GlobalVersion)]` with `#[clap(propagate_version = true)]`
902     ///
903     /// Builder: replace `cmd.setting(GlobalVersion)` with `cmd.propagate_version(true)`
904     #[cfg_attr(
905         feature = "deprecated",
906         deprecated(
907             since = "3.0.0",
908             note = "Replaced with `Command::propagate_version` and `Command::is_propagate_version_set`
909 
910 Derive: replace `#[clap(setting = GlobalVersion)]` with `#[clap(propagate_version = true)]`
911 
912 Builder: replace `cmd.setting(GlobalVersion)` with `cmd.propagate_version(true)`
913 "
914         )
915     )]
916     #[doc(hidden)]
917     GlobalVersion,
918 
919     /// Deprecated, replaced with [`Command::hide_possible_values`] and
920     /// [`Arg::is_hide_possible_values_set`]
921     ///
922     /// Derive: replace `#[clap(setting = HidePossibleValuesInHelp)]` with `#[clap(hide_possible_values = true)]`
923     ///
924     /// Builder: replace `cmd.setting(HidePossibleValuesInHelp)` with `cmd.hide_possible_values(true)`
925     #[cfg_attr(
926         feature = "deprecated",
927         deprecated(
928             since = "3.0.0",
929             note = "Replaced with `Command::hide_possible_values` and `Arg::is_hide_possible_values_set`
930 
931 Derive: replace `#[clap(setting = HidePossibleValuesInHelp)]` with `#[clap(hide_possible_values = true)]`
932 
933 Builder: replace `cmd.setting(HidePossibleValuesInHelp)` with `cmd.hide_possible_values(true)`
934 "
935         )
936     )]
937     #[doc(hidden)]
938     HidePossibleValuesInHelp,
939 
940     /// Deprecated, this is now the default
941     ///
942     /// Derive: remove `#[clap(setting = UnifiedHelp)]`
943     ///
944     /// Builder: remove `cmd.setting(UnifiedHelp)`
945     #[cfg_attr(
946         feature = "deprecated",
947         deprecated(
948             since = "3.0.0",
949             note = "This is now the default
950 
951 Derive: remove `#[clap(setting = UnifiedHelp)]`
952 
953 Builder: remove `cmd.setting(UnifiedHelp)`
954 "
955         )
956     )]
957     #[doc(hidden)]
958     UnifiedHelp,
959 
960     /// If the cmd is already built, used for caching.
961     #[doc(hidden)]
962     Built,
963 
964     /// If the cmd's bin name is already built, used for caching.
965     #[doc(hidden)]
966     BinNameBuilt,
967 }
968 
969 bitflags! {
970     struct Flags: u64 {
971         const SC_NEGATE_REQS                 = 1;
972         const SC_REQUIRED                    = 1 << 1;
973         const ARG_REQUIRED_ELSE_HELP         = 1 << 2;
974         const PROPAGATE_VERSION              = 1 << 3;
975         const DISABLE_VERSION_FOR_SC         = 1 << 4;
976         const WAIT_ON_ERROR                  = 1 << 6;
977         const SC_REQUIRED_ELSE_HELP          = 1 << 7;
978         const NO_AUTO_HELP                   = 1 << 8;
979         const NO_AUTO_VERSION                = 1 << 9;
980         const DISABLE_VERSION_FLAG           = 1 << 10;
981         const HIDDEN                         = 1 << 11;
982         const TRAILING_VARARG                = 1 << 12;
983         const NO_BIN_NAME                    = 1 << 13;
984         const ALLOW_UNK_SC                   = 1 << 14;
985         const SC_UTF8_NONE                   = 1 << 15;
986         const LEADING_HYPHEN                 = 1 << 16;
987         const NO_POS_VALUES                  = 1 << 17;
988         const NEXT_LINE_HELP                 = 1 << 18;
989         const DERIVE_DISP_ORDER              = 1 << 19;
990         const DISABLE_COLORED_HELP           = 1 << 20;
991         const COLOR_ALWAYS                   = 1 << 21;
992         const COLOR_AUTO                     = 1 << 22;
993         const COLOR_NEVER                    = 1 << 23;
994         const DONT_DELIM_TRAIL               = 1 << 24;
995         const ALLOW_NEG_NUMS                 = 1 << 25;
996         const DISABLE_HELP_SC                = 1 << 27;
997         const DONT_COLLAPSE_ARGS             = 1 << 28;
998         const ARGS_NEGATE_SCS                = 1 << 29;
999         const PROPAGATE_VALS_DOWN            = 1 << 30;
1000         const ALLOW_MISSING_POS              = 1 << 31;
1001         const TRAILING_VALUES                = 1 << 32;
1002         const BUILT                          = 1 << 33;
1003         const BIN_NAME_BUILT                 = 1 << 34;
1004         const VALID_ARG_FOUND                = 1 << 35;
1005         const INFER_SUBCOMMANDS              = 1 << 36;
1006         const CONTAINS_LAST                  = 1 << 37;
1007         const ARGS_OVERRIDE_SELF             = 1 << 38;
1008         const HELP_REQUIRED                  = 1 << 39;
1009         const SUBCOMMAND_PRECEDENCE_OVER_ARG = 1 << 40;
1010         const DISABLE_HELP_FLAG              = 1 << 41;
1011         const USE_LONG_FORMAT_FOR_HELP_SC    = 1 << 42;
1012         const INFER_LONG_ARGS                = 1 << 43;
1013         const IGNORE_ERRORS                  = 1 << 44;
1014         const MULTICALL                      = 1 << 45;
1015         const NO_OP                          = 0;
1016     }
1017 }
1018 
1019 impl_settings! { AppSettings, AppFlags,
1020     ArgRequiredElseHelp
1021         => Flags::ARG_REQUIRED_ELSE_HELP,
1022     SubcommandPrecedenceOverArg
1023         => Flags::SUBCOMMAND_PRECEDENCE_OVER_ARG,
1024     ArgsNegateSubcommands
1025         => Flags::ARGS_NEGATE_SCS,
1026     AllowExternalSubcommands
1027         => Flags::ALLOW_UNK_SC,
1028     StrictUtf8
1029         => Flags::NO_OP,
1030     AllowInvalidUtf8ForExternalSubcommands
1031         => Flags::SC_UTF8_NONE,
1032     AllowHyphenValues
1033         => Flags::LEADING_HYPHEN,
1034     AllowLeadingHyphen
1035         => Flags::LEADING_HYPHEN,
1036     AllowNegativeNumbers
1037         => Flags::ALLOW_NEG_NUMS,
1038     AllowMissingPositional
1039         => Flags::ALLOW_MISSING_POS,
1040     UnifiedHelpMessage
1041         => Flags::NO_OP,
1042     ColoredHelp
1043         => Flags::NO_OP,
1044     ColorAlways
1045         => Flags::COLOR_ALWAYS,
1046     ColorAuto
1047         => Flags::COLOR_AUTO,
1048     ColorNever
1049         => Flags::COLOR_NEVER,
1050     DontDelimitTrailingValues
1051         => Flags::DONT_DELIM_TRAIL,
1052     DontCollapseArgsInUsage
1053         => Flags::DONT_COLLAPSE_ARGS,
1054     DeriveDisplayOrder
1055         => Flags::DERIVE_DISP_ORDER,
1056     DisableColoredHelp
1057         => Flags::DISABLE_COLORED_HELP,
1058     DisableHelpSubcommand
1059         => Flags::DISABLE_HELP_SC,
1060     DisableHelpFlag
1061         => Flags::DISABLE_HELP_FLAG,
1062     DisableHelpFlags
1063         => Flags::DISABLE_HELP_FLAG,
1064     DisableVersionFlag
1065         => Flags::DISABLE_VERSION_FLAG,
1066     DisableVersion
1067         => Flags::DISABLE_VERSION_FLAG,
1068     PropagateVersion
1069         => Flags::PROPAGATE_VERSION,
1070     GlobalVersion
1071         => Flags::PROPAGATE_VERSION,
1072     HidePossibleValues
1073         => Flags::NO_POS_VALUES,
1074     HidePossibleValuesInHelp
1075         => Flags::NO_POS_VALUES,
1076     HelpExpected
1077         => Flags::HELP_REQUIRED,
1078     Hidden
1079         => Flags::HIDDEN,
1080     Multicall
1081         => Flags::MULTICALL,
1082     NoAutoHelp
1083         => Flags::NO_AUTO_HELP,
1084     NoAutoVersion
1085         => Flags::NO_AUTO_VERSION,
1086     NoBinaryName
1087         => Flags::NO_BIN_NAME,
1088     SubcommandsNegateReqs
1089         => Flags::SC_NEGATE_REQS,
1090     SubcommandRequired
1091         => Flags::SC_REQUIRED,
1092     SubcommandRequiredElseHelp
1093         => Flags::SC_REQUIRED_ELSE_HELP,
1094     UseLongFormatForHelpSubcommand
1095         => Flags::USE_LONG_FORMAT_FOR_HELP_SC,
1096     TrailingVarArg
1097         => Flags::TRAILING_VARARG,
1098     UnifiedHelp => Flags::NO_OP,
1099     NextLineHelp
1100         => Flags::NEXT_LINE_HELP,
1101     IgnoreErrors
1102         => Flags::IGNORE_ERRORS,
1103     WaitOnError
1104         => Flags::WAIT_ON_ERROR,
1105     Built
1106         => Flags::BUILT,
1107     BinNameBuilt
1108         => Flags::BIN_NAME_BUILT,
1109     InferSubcommands
1110         => Flags::INFER_SUBCOMMANDS,
1111     AllArgsOverrideSelf
1112         => Flags::ARGS_OVERRIDE_SELF,
1113     InferLongArgs
1114         => Flags::INFER_LONG_ARGS
1115 }
1116 
1117 /// Deprecated in [Issue #3087](https://github.com/clap-rs/clap/issues/3087), maybe [`clap::Parser`][crate::Parser] would fit your use case?
1118 #[cfg(feature = "yaml")]
1119 impl FromStr for AppSettings {
1120     type Err = String;
from_str(s: &str) -> Result<Self, <Self as FromStr>::Err>1121     fn from_str(s: &str) -> Result<Self, <Self as FromStr>::Err> {
1122         #[allow(deprecated)]
1123         #[allow(unreachable_patterns)]
1124         match &*s.to_ascii_lowercase() {
1125             "argrequiredelsehelp" => Ok(AppSettings::ArgRequiredElseHelp),
1126             "subcommandprecedenceoverarg" => Ok(AppSettings::SubcommandPrecedenceOverArg),
1127             "argsnegatesubcommands" => Ok(AppSettings::ArgsNegateSubcommands),
1128             "allowexternalsubcommands" => Ok(AppSettings::AllowExternalSubcommands),
1129             "strictutf8" => Ok(AppSettings::StrictUtf8),
1130             "allowinvalidutf8forexternalsubcommands" => {
1131                 Ok(AppSettings::AllowInvalidUtf8ForExternalSubcommands)
1132             }
1133             "allowhyphenvalues" => Ok(AppSettings::AllowHyphenValues),
1134             "allowleadinghyphen" => Ok(AppSettings::AllowLeadingHyphen),
1135             "allownegativenumbers" => Ok(AppSettings::AllowNegativeNumbers),
1136             "allowmissingpositional" => Ok(AppSettings::AllowMissingPositional),
1137             "unifiedhelpmessage" => Ok(AppSettings::UnifiedHelpMessage),
1138             "coloredhelp" => Ok(AppSettings::ColoredHelp),
1139             "coloralways" => Ok(AppSettings::ColorAlways),
1140             "colorauto" => Ok(AppSettings::ColorAuto),
1141             "colornever" => Ok(AppSettings::ColorNever),
1142             "dontdelimittrailingvalues" => Ok(AppSettings::DontDelimitTrailingValues),
1143             "dontcollapseargsinusage" => Ok(AppSettings::DontCollapseArgsInUsage),
1144             "derivedisplayorder" => Ok(AppSettings::DeriveDisplayOrder),
1145             "disablecoloredhelp" => Ok(AppSettings::DisableColoredHelp),
1146             "disablehelpsubcommand" => Ok(AppSettings::DisableHelpSubcommand),
1147             "disablehelpflag" => Ok(AppSettings::DisableHelpFlag),
1148             "disablehelpflags" => Ok(AppSettings::DisableHelpFlags),
1149             "disableversionflag" => Ok(AppSettings::DisableVersionFlag),
1150             "disableversion" => Ok(AppSettings::DisableVersion),
1151             "propagateversion" => Ok(AppSettings::PropagateVersion),
1152             "propagateversion" => Ok(AppSettings::GlobalVersion),
1153             "hidepossiblevalues" => Ok(AppSettings::HidePossibleValues),
1154             "hidepossiblevaluesinhelp" => Ok(AppSettings::HidePossibleValuesInHelp),
1155             "helpexpected" => Ok(AppSettings::HelpExpected),
1156             "hidden" => Ok(AppSettings::Hidden),
1157             "noautohelp" => Ok(AppSettings::NoAutoHelp),
1158             "noautoversion" => Ok(AppSettings::NoAutoVersion),
1159             "nobinaryname" => Ok(AppSettings::NoBinaryName),
1160             "subcommandsnegatereqs" => Ok(AppSettings::SubcommandsNegateReqs),
1161             "subcommandrequired" => Ok(AppSettings::SubcommandRequired),
1162             "subcommandrequiredelsehelp" => Ok(AppSettings::SubcommandRequiredElseHelp),
1163             "uselongformatforhelpsubcommand" => Ok(AppSettings::UseLongFormatForHelpSubcommand),
1164             "trailingvararg" => Ok(AppSettings::TrailingVarArg),
1165             "unifiedhelp" => Ok(AppSettings::UnifiedHelp),
1166             "nextlinehelp" => Ok(AppSettings::NextLineHelp),
1167             "ignoreerrors" => Ok(AppSettings::IgnoreErrors),
1168             "waitonerror" => Ok(AppSettings::WaitOnError),
1169             "built" => Ok(AppSettings::Built),
1170             "binnamebuilt" => Ok(AppSettings::BinNameBuilt),
1171             "infersubcommands" => Ok(AppSettings::InferSubcommands),
1172             "allargsoverrideself" => Ok(AppSettings::AllArgsOverrideSelf),
1173             "inferlongargs" => Ok(AppSettings::InferLongArgs),
1174             _ => Err(format!("unknown AppSetting: `{}`", s)),
1175         }
1176     }
1177 }
1178 
1179 #[cfg(test)]
1180 mod test {
1181     #[allow(clippy::cognitive_complexity)]
1182     #[test]
1183     #[cfg(feature = "yaml")]
app_settings_fromstr()1184     fn app_settings_fromstr() {
1185         use super::AppSettings;
1186 
1187         assert_eq!(
1188             "disablehelpflag".parse::<AppSettings>().unwrap(),
1189             AppSettings::DisableHelpFlag
1190         );
1191         assert_eq!(
1192             "argsnegatesubcommands".parse::<AppSettings>().unwrap(),
1193             AppSettings::ArgsNegateSubcommands
1194         );
1195         assert_eq!(
1196             "argrequiredelsehelp".parse::<AppSettings>().unwrap(),
1197             AppSettings::ArgRequiredElseHelp
1198         );
1199         assert_eq!(
1200             "subcommandprecedenceoverarg"
1201                 .parse::<AppSettings>()
1202                 .unwrap(),
1203             AppSettings::SubcommandPrecedenceOverArg
1204         );
1205         assert_eq!(
1206             "allowexternalsubcommands".parse::<AppSettings>().unwrap(),
1207             AppSettings::AllowExternalSubcommands
1208         );
1209         assert_eq!(
1210             "allowinvalidutf8forexternalsubcommands"
1211                 .parse::<AppSettings>()
1212                 .unwrap(),
1213             AppSettings::AllowInvalidUtf8ForExternalSubcommands
1214         );
1215         assert_eq!(
1216             "allowhyphenvalues".parse::<AppSettings>().unwrap(),
1217             AppSettings::AllowHyphenValues
1218         );
1219         assert_eq!(
1220             "allownegativenumbers".parse::<AppSettings>().unwrap(),
1221             AppSettings::AllowNegativeNumbers
1222         );
1223         assert_eq!(
1224             "disablehelpsubcommand".parse::<AppSettings>().unwrap(),
1225             AppSettings::DisableHelpSubcommand
1226         );
1227         assert_eq!(
1228             "disableversionflag".parse::<AppSettings>().unwrap(),
1229             AppSettings::DisableVersionFlag
1230         );
1231         assert_eq!(
1232             "dontcollapseargsinusage".parse::<AppSettings>().unwrap(),
1233             AppSettings::DontCollapseArgsInUsage
1234         );
1235         assert_eq!(
1236             "dontdelimittrailingvalues".parse::<AppSettings>().unwrap(),
1237             AppSettings::DontDelimitTrailingValues
1238         );
1239         assert_eq!(
1240             "derivedisplayorder".parse::<AppSettings>().unwrap(),
1241             AppSettings::DeriveDisplayOrder
1242         );
1243         assert_eq!(
1244             "disablecoloredhelp".parse::<AppSettings>().unwrap(),
1245             AppSettings::DisableColoredHelp
1246         );
1247         assert_eq!(
1248             "propagateversion".parse::<AppSettings>().unwrap(),
1249             AppSettings::PropagateVersion
1250         );
1251         assert_eq!(
1252             "hidden".parse::<AppSettings>().unwrap(),
1253             AppSettings::Hidden
1254         );
1255         assert_eq!(
1256             "hidepossiblevalues".parse::<AppSettings>().unwrap(),
1257             AppSettings::HidePossibleValues
1258         );
1259         assert_eq!(
1260             "helpexpected".parse::<AppSettings>().unwrap(),
1261             AppSettings::HelpExpected
1262         );
1263         assert_eq!(
1264             "nobinaryname".parse::<AppSettings>().unwrap(),
1265             AppSettings::NoBinaryName
1266         );
1267         assert_eq!(
1268             "nextlinehelp".parse::<AppSettings>().unwrap(),
1269             AppSettings::NextLineHelp
1270         );
1271         assert_eq!(
1272             "subcommandsnegatereqs".parse::<AppSettings>().unwrap(),
1273             AppSettings::SubcommandsNegateReqs
1274         );
1275         assert_eq!(
1276             "subcommandrequired".parse::<AppSettings>().unwrap(),
1277             AppSettings::SubcommandRequired
1278         );
1279         assert_eq!(
1280             "subcommandrequiredelsehelp".parse::<AppSettings>().unwrap(),
1281             AppSettings::SubcommandRequiredElseHelp
1282         );
1283         assert_eq!(
1284             "uselongformatforhelpsubcommand"
1285                 .parse::<AppSettings>()
1286                 .unwrap(),
1287             AppSettings::UseLongFormatForHelpSubcommand
1288         );
1289         assert_eq!(
1290             "trailingvararg".parse::<AppSettings>().unwrap(),
1291             AppSettings::TrailingVarArg
1292         );
1293         assert_eq!(
1294             "waitonerror".parse::<AppSettings>().unwrap(),
1295             AppSettings::WaitOnError
1296         );
1297         assert_eq!("built".parse::<AppSettings>().unwrap(), AppSettings::Built);
1298         assert_eq!(
1299             "binnamebuilt".parse::<AppSettings>().unwrap(),
1300             AppSettings::BinNameBuilt
1301         );
1302         assert_eq!(
1303             "infersubcommands".parse::<AppSettings>().unwrap(),
1304             AppSettings::InferSubcommands
1305         );
1306         assert!("hahahaha".parse::<AppSettings>().is_err());
1307     }
1308 }
1309