clap/app/
settings.rs

1// Std
2#[allow(deprecated, unused_imports)]
3use std::ascii::AsciiExt;
4use std::ops::BitOr;
5use std::str::FromStr;
6
7bitflags! {
8    struct Flags: u64 {
9        const SC_NEGATE_REQS       = 1;
10        const SC_REQUIRED          = 1 << 1;
11        const A_REQUIRED_ELSE_HELP = 1 << 2;
12        const GLOBAL_VERSION       = 1 << 3;
13        const VERSIONLESS_SC       = 1 << 4;
14        const UNIFIED_HELP         = 1 << 5;
15        const WAIT_ON_ERROR        = 1 << 6;
16        const SC_REQUIRED_ELSE_HELP= 1 << 7;
17        const NEEDS_LONG_HELP      = 1 << 8;
18        const NEEDS_LONG_VERSION   = 1 << 9;
19        const NEEDS_SC_HELP        = 1 << 10;
20        const DISABLE_VERSION      = 1 << 11;
21        const HIDDEN               = 1 << 12;
22        const TRAILING_VARARG      = 1 << 13;
23        const NO_BIN_NAME          = 1 << 14;
24        const ALLOW_UNK_SC         = 1 << 15;
25        const UTF8_STRICT          = 1 << 16;
26        const UTF8_NONE            = 1 << 17;
27        const LEADING_HYPHEN       = 1 << 18;
28        const NO_POS_VALUES        = 1 << 19;
29        const NEXT_LINE_HELP       = 1 << 20;
30        const DERIVE_DISP_ORDER    = 1 << 21;
31        const COLORED_HELP         = 1 << 22;
32        const COLOR_ALWAYS         = 1 << 23;
33        const COLOR_AUTO           = 1 << 24;
34        const COLOR_NEVER          = 1 << 25;
35        const DONT_DELIM_TRAIL     = 1 << 26;
36        const ALLOW_NEG_NUMS       = 1 << 27;
37        const LOW_INDEX_MUL_POS    = 1 << 28;
38        const DISABLE_HELP_SC      = 1 << 29;
39        const DONT_COLLAPSE_ARGS   = 1 << 30;
40        const ARGS_NEGATE_SCS      = 1 << 31;
41        const PROPAGATE_VALS_DOWN  = 1 << 32;
42        const ALLOW_MISSING_POS    = 1 << 33;
43        const TRAILING_VALUES      = 1 << 34;
44        const VALID_NEG_NUM_FOUND  = 1 << 35;
45        const PROPAGATED           = 1 << 36;
46        const VALID_ARG_FOUND      = 1 << 37;
47        const INFER_SUBCOMMANDS    = 1 << 38;
48        const CONTAINS_LAST        = 1 << 39;
49        const ARGS_OVERRIDE_SELF   = 1 << 40;
50        const DISABLE_HELP_FLAGS   = 1 << 41;
51    }
52}
53
54#[doc(hidden)]
55#[derive(Debug, Copy, Clone, PartialEq)]
56pub struct AppFlags(Flags);
57
58impl BitOr for AppFlags {
59    type Output = Self;
60    fn bitor(self, rhs: Self) -> Self {
61        AppFlags(self.0 | rhs.0)
62    }
63}
64
65impl Default for AppFlags {
66    fn default() -> Self {
67        AppFlags(
68            Flags::NEEDS_LONG_VERSION
69                | Flags::NEEDS_LONG_HELP
70                | Flags::NEEDS_SC_HELP
71                | Flags::UTF8_NONE
72                | Flags::COLOR_AUTO,
73        )
74    }
75}
76
77#[allow(deprecated)]
78impl AppFlags {
79    pub fn new() -> Self {
80        AppFlags::default()
81    }
82    pub fn zeroed() -> Self {
83        AppFlags(Flags::empty())
84    }
85
86    impl_settings! { AppSettings,
87        ArgRequiredElseHelp => Flags::A_REQUIRED_ELSE_HELP,
88        ArgsNegateSubcommands => Flags::ARGS_NEGATE_SCS,
89        AllArgsOverrideSelf => Flags::ARGS_OVERRIDE_SELF,
90        AllowExternalSubcommands => Flags::ALLOW_UNK_SC,
91        AllowInvalidUtf8 => Flags::UTF8_NONE,
92        AllowLeadingHyphen => Flags::LEADING_HYPHEN,
93        AllowNegativeNumbers => Flags::ALLOW_NEG_NUMS,
94        AllowMissingPositional => Flags::ALLOW_MISSING_POS,
95        ColoredHelp => Flags::COLORED_HELP,
96        ColorAlways => Flags::COLOR_ALWAYS,
97        ColorAuto => Flags::COLOR_AUTO,
98        ColorNever => Flags::COLOR_NEVER,
99        DontDelimitTrailingValues => Flags::DONT_DELIM_TRAIL,
100        DontCollapseArgsInUsage => Flags::DONT_COLLAPSE_ARGS,
101        DeriveDisplayOrder => Flags::DERIVE_DISP_ORDER,
102        DisableHelpFlags => Flags::DISABLE_HELP_FLAGS,
103        DisableHelpSubcommand => Flags::DISABLE_HELP_SC,
104        DisableVersion => Flags::DISABLE_VERSION,
105        GlobalVersion => Flags::GLOBAL_VERSION,
106        HidePossibleValuesInHelp => Flags::NO_POS_VALUES,
107        Hidden => Flags::HIDDEN,
108        LowIndexMultiplePositional => Flags::LOW_INDEX_MUL_POS,
109        NeedsLongHelp => Flags::NEEDS_LONG_HELP,
110        NeedsLongVersion => Flags::NEEDS_LONG_VERSION,
111        NeedsSubcommandHelp => Flags::NEEDS_SC_HELP,
112        NoBinaryName => Flags::NO_BIN_NAME,
113        PropagateGlobalValuesDown=> Flags::PROPAGATE_VALS_DOWN,
114        StrictUtf8 => Flags::UTF8_STRICT,
115        SubcommandsNegateReqs => Flags::SC_NEGATE_REQS,
116        SubcommandRequired => Flags::SC_REQUIRED,
117        SubcommandRequiredElseHelp => Flags::SC_REQUIRED_ELSE_HELP,
118        TrailingVarArg => Flags::TRAILING_VARARG,
119        UnifiedHelpMessage => Flags::UNIFIED_HELP,
120        NextLineHelp => Flags::NEXT_LINE_HELP,
121        VersionlessSubcommands => Flags::VERSIONLESS_SC,
122        WaitOnError => Flags::WAIT_ON_ERROR,
123        TrailingValues => Flags::TRAILING_VALUES,
124        ValidNegNumFound => Flags::VALID_NEG_NUM_FOUND,
125        Propagated => Flags::PROPAGATED,
126        ValidArgFound => Flags::VALID_ARG_FOUND,
127        InferSubcommands => Flags::INFER_SUBCOMMANDS,
128        ContainsLast => Flags::CONTAINS_LAST
129    }
130}
131
132/// Application level settings, which affect how [`App`] operates
133///
134/// **NOTE:** When these settings are used, they apply only to current command, and are *not*
135/// propagated down or up through child or parent subcommands
136///
137/// [`App`]: ./struct.App.html
138#[derive(Debug, PartialEq, Copy, Clone)]
139pub enum AppSettings {
140    /// Specifies that any invalid UTF-8 code points should *not* be treated as an error.
141    /// This is the default behavior of `clap`.
142    ///
143    /// **NOTE:** Using argument values with invalid UTF-8 code points requires using
144    /// [`ArgMatches::os_value_of`], [`ArgMatches::os_values_of`], [`ArgMatches::lossy_value_of`],
145    /// or [`ArgMatches::lossy_values_of`] for those particular arguments which may contain invalid
146    /// UTF-8 values
147    ///
148    /// **NOTE:** This rule only applies to  argument values, as flags, options, and
149    /// [`SubCommand`]s themselves only allow valid UTF-8 code points.
150    ///
151    /// # Platform Specific
152    ///
153    /// Non Windows systems only
154    ///
155    /// # Examples
156    ///
157    #[cfg_attr(not(unix), doc = " ```ignore")]
158    #[cfg_attr(unix, doc = " ```")]
159    /// # use clap::{App, AppSettings};
160    /// use std::ffi::OsString;
161    /// use std::os::unix::ffi::{OsStrExt,OsStringExt};
162    ///
163    /// let r = App::new("myprog")
164    ///   //.setting(AppSettings::AllowInvalidUtf8)
165    ///     .arg_from_usage("<arg> 'some positional arg'")
166    ///     .get_matches_from_safe(
167    ///         vec![
168    ///             OsString::from("myprog"),
169    ///             OsString::from_vec(vec![0xe9])]);
170    ///
171    /// assert!(r.is_ok());
172    /// let m = r.unwrap();
173    /// assert_eq!(m.value_of_os("arg").unwrap().as_bytes(), &[0xe9]);
174    /// ```
175    /// [`ArgMatches::os_value_of`]: ./struct.ArgMatches.html#method.os_value_of
176    /// [`ArgMatches::os_values_of`]: ./struct.ArgMatches.html#method.os_values_of
177    /// [`ArgMatches::lossy_value_of`]: ./struct.ArgMatches.html#method.lossy_value_of
178    /// [`ArgMatches::lossy_values_of`]: ./struct.ArgMatches.html#method.lossy_values_of
179    /// [`SubCommand`]: ./struct.SubCommand.html
180    AllowInvalidUtf8,
181
182    /// Essentially sets [`Arg::overrides_with("itself")`] for all arguments.
183    ///
184    /// **WARNING:** Positional arguments cannot override themselves (or we would never be able
185    /// to advance to the next positional). This setting ignores positional arguments.
186    /// [`Arg::overrides_with("itself")`]: ./struct.Arg.html#method.overrides_with
187    AllArgsOverrideSelf,
188
189    /// Specifies that leading hyphens are allowed in argument *values*, such as negative numbers
190    /// like `-10`. (which would otherwise be parsed as another flag or option)
191    ///
192    /// **NOTE:** Use this setting with caution as it silences certain circumstances which would
193    /// otherwise be an error (such as accidentally forgetting to specify a value for leading
194    /// option). It is preferred to set this on a per argument basis, via [`Arg::allow_hyphen_values`]
195    ///
196    /// # Examples
197    ///
198    /// ```rust
199    /// # use clap::{Arg, App, AppSettings};
200    /// // Imagine you needed to represent negative numbers as well, such as -10
201    /// let m = App::new("nums")
202    ///     .setting(AppSettings::AllowLeadingHyphen)
203    ///     .arg(Arg::with_name("neg").index(1))
204    ///     .get_matches_from(vec![
205    ///         "nums", "-20"
206    ///     ]);
207    ///
208    /// assert_eq!(m.value_of("neg"), Some("-20"));
209    /// # ;
210    /// ```
211    /// [`Arg::allow_hyphen_values`]: ./struct.Arg.html#method.allow_hyphen_values
212    AllowLeadingHyphen,
213
214    /// Allows negative numbers to pass as values. This is similar to
215    /// `AllowLeadingHyphen` except that it only allows numbers, all
216    /// other undefined leading hyphens will fail to parse.
217    ///
218    /// # Examples
219    ///
220    /// ```rust
221    /// # use clap::{App, Arg, AppSettings};
222    /// let res = App::new("myprog")
223    ///     .version("v1.1")
224    ///     .setting(AppSettings::AllowNegativeNumbers)
225    ///     .arg(Arg::with_name("num"))
226    ///     .get_matches_from_safe(vec![
227    ///         "myprog", "-20"
228    ///     ]);
229    /// assert!(res.is_ok());
230    /// let m = res.unwrap();
231    /// assert_eq!(m.value_of("num").unwrap(), "-20");
232    /// ```
233    /// [`AllowLeadingHyphen`]: ./enum.AppSettings.html#variant.AllowLeadingHyphen
234    AllowNegativeNumbers,
235
236    /// Allows one to implement two styles of CLIs where positionals can be used out of order.
237    ///
238    /// The first example is a CLI where the second to last positional argument is optional, but
239    /// the final positional argument is required. Such as `$ prog [optional] <required>` where one
240    /// of the two following usages is allowed:
241    ///
242    /// * `$ prog [optional] <required>`
243    /// * `$ prog <required>`
244    ///
245    /// This would otherwise not be allowed. This is useful when `[optional]` has a default value.
246    ///
247    /// **Note:** when using this style of "missing positionals" the final positional *must* be
248    /// [required] if `--` will not be used to skip to the final positional argument.
249    ///
250    /// **Note:** This style also only allows a single positional argument to be "skipped" without
251    /// the use of `--`. To skip more than one, see the second example.
252    ///
253    /// The second example is when one wants to skip multiple optional positional arguments, and use
254    /// of the `--` operator is OK (but not required if all arguments will be specified anyways).
255    ///
256    /// For example, imagine a CLI which has three positional arguments `[foo] [bar] [baz]...` where
257    /// `baz` accepts multiple values (similar to man `ARGS...` style training arguments).
258    ///
259    /// With this setting the following invocations are possible:
260    ///
261    /// * `$ prog foo bar baz1 baz2 baz3`
262    /// * `$ prog foo -- baz1 baz2 baz3`
263    /// * `$ prog -- baz1 baz2 baz3`
264    ///
265    /// # Examples
266    ///
267    /// Style number one from above:
268    ///
269    /// ```rust
270    /// # use clap::{App, Arg, AppSettings};
271    /// // Assume there is an external subcommand named "subcmd"
272    /// let m = App::new("myprog")
273    ///     .setting(AppSettings::AllowMissingPositional)
274    ///     .arg(Arg::with_name("arg1"))
275    ///     .arg(Arg::with_name("arg2")
276    ///         .required(true))
277    ///     .get_matches_from(vec![
278    ///         "prog", "other"
279    ///     ]);
280    ///
281    /// assert_eq!(m.value_of("arg1"), None);
282    /// assert_eq!(m.value_of("arg2"), Some("other"));
283    /// ```
284    ///
285    /// Now the same example, but using a default value for the first optional positional argument
286    ///
287    /// ```rust
288    /// # use clap::{App, Arg, AppSettings};
289    /// // Assume there is an external subcommand named "subcmd"
290    /// let m = App::new("myprog")
291    ///     .setting(AppSettings::AllowMissingPositional)
292    ///     .arg(Arg::with_name("arg1")
293    ///         .default_value("something"))
294    ///     .arg(Arg::with_name("arg2")
295    ///         .required(true))
296    ///     .get_matches_from(vec![
297    ///         "prog", "other"
298    ///     ]);
299    ///
300    /// assert_eq!(m.value_of("arg1"), Some("something"));
301    /// assert_eq!(m.value_of("arg2"), Some("other"));
302    /// ```
303    /// Style number two from above:
304    ///
305    /// ```rust
306    /// # use clap::{App, Arg, AppSettings};
307    /// // Assume there is an external subcommand named "subcmd"
308    /// let m = App::new("myprog")
309    ///     .setting(AppSettings::AllowMissingPositional)
310    ///     .arg(Arg::with_name("foo"))
311    ///     .arg(Arg::with_name("bar"))
312    ///     .arg(Arg::with_name("baz").multiple(true))
313    ///     .get_matches_from(vec![
314    ///         "prog", "foo", "bar", "baz1", "baz2", "baz3"
315    ///     ]);
316    ///
317    /// assert_eq!(m.value_of("foo"), Some("foo"));
318    /// assert_eq!(m.value_of("bar"), Some("bar"));
319    /// assert_eq!(m.values_of("baz").unwrap().collect::<Vec<_>>(), &["baz1", "baz2", "baz3"]);
320    /// ```
321    ///
322    /// Now notice if we don't specify `foo` or `baz` but use the `--` operator.
323    ///
324    /// ```rust
325    /// # use clap::{App, Arg, AppSettings};
326    /// // Assume there is an external subcommand named "subcmd"
327    /// let m = App::new("myprog")
328    ///     .setting(AppSettings::AllowMissingPositional)
329    ///     .arg(Arg::with_name("foo"))
330    ///     .arg(Arg::with_name("bar"))
331    ///     .arg(Arg::with_name("baz").multiple(true))
332    ///     .get_matches_from(vec![
333    ///         "prog", "--", "baz1", "baz2", "baz3"
334    ///     ]);
335    ///
336    /// assert_eq!(m.value_of("foo"), None);
337    /// assert_eq!(m.value_of("bar"), None);
338    /// assert_eq!(m.values_of("baz").unwrap().collect::<Vec<_>>(), &["baz1", "baz2", "baz3"]);
339    /// ```
340    /// [required]: ./struct.Arg.html#method.required
341    AllowMissingPositional,
342
343    /// Specifies that an unexpected positional argument,
344    /// which would otherwise cause a [`ErrorKind::UnknownArgument`] error,
345    /// should instead be treated as a [`SubCommand`] within the [`ArgMatches`] struct.
346    ///
347    /// **NOTE:** Use this setting with caution,
348    /// as a truly unexpected argument (i.e. one that is *NOT* an external subcommand)
349    /// will **not** cause an error and instead be treated as a potential subcommand.
350    /// One should check for such cases manually and inform the user appropriately.
351    ///
352    /// # Examples
353    ///
354    /// ```rust
355    /// # use clap::{App, AppSettings};
356    /// // Assume there is an external subcommand named "subcmd"
357    /// let m = App::new("myprog")
358    ///     .setting(AppSettings::AllowExternalSubcommands)
359    ///     .get_matches_from(vec![
360    ///         "myprog", "subcmd", "--option", "value", "-fff", "--flag"
361    ///     ]);
362    ///
363    /// // All trailing arguments will be stored under the subcommand's sub-matches using an empty
364    /// // string argument name
365    /// match m.subcommand() {
366    ///     (external, Some(ext_m)) => {
367    ///          let ext_args: Vec<&str> = ext_m.values_of("").unwrap().collect();
368    ///          assert_eq!(external, "subcmd");
369    ///          assert_eq!(ext_args, ["--option", "value", "-fff", "--flag"]);
370    ///     },
371    ///     _ => {},
372    /// }
373    /// ```
374    /// [`ErrorKind::UnknownArgument`]: ./enum.ErrorKind.html#variant.UnknownArgument
375    /// [`SubCommand`]: ./struct.SubCommand.html
376    /// [`ArgMatches`]: ./struct.ArgMatches.html
377    AllowExternalSubcommands,
378
379    /// Specifies that use of a valid [argument] negates [subcommands] being used after. By default
380    /// `clap` allows arguments between subcommands such as
381    /// `<cmd> [cmd_args] <cmd2> [cmd2_args] <cmd3> [cmd3_args]`. This setting disables that
382    /// functionality and says that arguments can only follow the *final* subcommand. For instance
383    /// using this setting makes only the following invocations possible:
384    ///
385    /// * `<cmd> <cmd2> <cmd3> [cmd3_args]`
386    /// * `<cmd> <cmd2> [cmd2_args]`
387    /// * `<cmd> [cmd_args]`
388    ///
389    /// # Examples
390    ///
391    /// ```rust
392    /// # use clap::{App, AppSettings};
393    /// App::new("myprog")
394    ///     .setting(AppSettings::ArgsNegateSubcommands)
395    /// # ;
396    /// ```
397    /// [subcommands]: ./struct.SubCommand.html
398    /// [argument]: ./struct.Arg.html
399    ArgsNegateSubcommands,
400
401    /// Specifies that the help text should be displayed (and then exit gracefully),
402    /// if no arguments are present at runtime (i.e. an empty run such as, `$ myprog`.
403    ///
404    /// **NOTE:** [`SubCommand`]s count as arguments
405    ///
406    /// **NOTE:** Setting [`Arg::default_value`] effectively disables this option as it will
407    /// ensure that some argument is always present.
408    ///
409    /// # Examples
410    ///
411    /// ```rust
412    /// # use clap::{App, AppSettings};
413    /// App::new("myprog")
414    ///     .setting(AppSettings::ArgRequiredElseHelp)
415    /// # ;
416    /// ```
417    /// [`SubCommand`]: ./struct.SubCommand.html
418    /// [`Arg::default_value`]: ./struct.Arg.html#method.default_value
419    ArgRequiredElseHelp,
420
421    /// Uses colorized help messages.
422    ///
423    /// **NOTE:** Must be compiled with the `color` cargo feature
424    ///
425    /// # Platform Specific
426    ///
427    /// This setting only applies to Unix, Linux, and macOS (i.e. non-Windows platforms)
428    ///
429    /// # Examples
430    ///
431    /// ```no_run
432    /// # use clap::{App, Arg, SubCommand, AppSettings};
433    /// App::new("myprog")
434    ///     .setting(AppSettings::ColoredHelp)
435    ///     .get_matches();
436    /// ```
437    ColoredHelp,
438
439    /// Enables colored output only when the output is going to a terminal or TTY.
440    ///
441    /// **NOTE:** This is the default behavior of `clap`.
442    ///
443    /// **NOTE:** Must be compiled with the `color` cargo feature.
444    ///
445    /// # Platform Specific
446    ///
447    /// This setting only applies to Unix, Linux, and macOS (i.e. non-Windows platforms).
448    ///
449    /// # Examples
450    ///
451    /// ```no_run
452    /// # use clap::{App, Arg, SubCommand, AppSettings};
453    /// App::new("myprog")
454    ///     .setting(AppSettings::ColorAuto)
455    ///     .get_matches();
456    /// ```
457    ColorAuto,
458
459    /// Enables colored output regardless of whether or not the output is going to a terminal/TTY.
460    ///
461    /// **NOTE:** Must be compiled with the `color` cargo feature.
462    ///
463    /// # Platform Specific
464    ///
465    /// This setting only applies to Unix, Linux, and macOS (i.e. non-Windows platforms).
466    ///
467    /// # Examples
468    ///
469    /// ```no_run
470    /// # use clap::{App, Arg, SubCommand, AppSettings};
471    /// App::new("myprog")
472    ///     .setting(AppSettings::ColorAlways)
473    ///     .get_matches();
474    /// ```
475    ColorAlways,
476
477    /// Disables colored output no matter if the output is going to a terminal/TTY, or not.
478    ///
479    /// **NOTE:** Must be compiled with the `color` cargo feature
480    ///
481    /// # Platform Specific
482    ///
483    /// This setting only applies to Unix, Linux, and macOS (i.e. non-Windows platforms)
484    ///
485    /// # Examples
486    ///
487    /// ```no_run
488    /// # use clap::{App, Arg, SubCommand, AppSettings};
489    /// App::new("myprog")
490    ///     .setting(AppSettings::ColorNever)
491    ///     .get_matches();
492    /// ```
493    ColorNever,
494
495    /// Disables the automatic collapsing of positional args into `[ARGS]` inside the usage string
496    ///
497    /// # Examples
498    ///
499    /// ```no_run
500    /// # use clap::{App, Arg, SubCommand, AppSettings};
501    /// App::new("myprog")
502    ///     .setting(AppSettings::DontCollapseArgsInUsage)
503    ///     .get_matches();
504    /// ```
505    DontCollapseArgsInUsage,
506
507    /// Disables the automatic delimiting of values when `--` or [`AppSettings::TrailingVarArg`]
508    /// was used.
509    ///
510    /// **NOTE:** The same thing can be done manually by setting the final positional argument to
511    /// [`Arg::use_delimiter(false)`]. Using this setting is safer, because it's easier to locate
512    /// when making changes.
513    ///
514    /// # Examples
515    ///
516    /// ```no_run
517    /// # use clap::{App, Arg, SubCommand, AppSettings};
518    /// App::new("myprog")
519    ///     .setting(AppSettings::DontDelimitTrailingValues)
520    ///     .get_matches();
521    /// ```
522    /// [`AppSettings::TrailingVarArg`]: ./enum.AppSettings.html#variant.TrailingVarArg
523    /// [`Arg::use_delimiter(false)`]: ./struct.Arg.html#method.use_delimiter
524    DontDelimitTrailingValues,
525
526    /// Disables `-h` and `--help` [`App`] without affecting any of the [`SubCommand`]s
527    /// (Defaults to `false`; application *does* have help flags)
528    ///
529    /// # Examples
530    ///
531    /// ```rust
532    /// # use clap::{App, AppSettings, ErrorKind};
533    /// let res = App::new("myprog")
534    ///     .setting(AppSettings::DisableHelpFlags)
535    ///     .get_matches_from_safe(vec![
536    ///         "myprog", "-h"
537    ///     ]);
538    /// assert!(res.is_err());
539    /// assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
540    /// ```
541    ///
542    /// ```rust
543    /// # use clap::{App, SubCommand, AppSettings, ErrorKind};
544    /// let res = App::new("myprog")
545    ///     .setting(AppSettings::DisableHelpFlags)
546    ///     .subcommand(SubCommand::with_name("test"))
547    ///     .get_matches_from_safe(vec![
548    ///         "myprog", "test", "-h"
549    ///     ]);
550    /// assert!(res.is_err());
551    /// assert_eq!(res.unwrap_err().kind, ErrorKind::HelpDisplayed);
552    /// ```
553    /// [`SubCommand`]: ./struct.SubCommand.html
554    /// [`App`]: ./struct.App.html
555    DisableHelpFlags,
556
557    /// Disables the `help` subcommand
558    ///
559    /// # Examples
560    ///
561    /// ```rust
562    /// # use clap::{App, AppSettings, ErrorKind, SubCommand};
563    /// let res = App::new("myprog")
564    ///     .version("v1.1")
565    ///     .setting(AppSettings::DisableHelpSubcommand)
566    ///     // Normally, creating a subcommand causes a `help` subcommand to automatically
567    ///     // be generated as well
568    ///     .subcommand(SubCommand::with_name("test"))
569    ///     .get_matches_from_safe(vec![
570    ///         "myprog", "help"
571    ///     ]);
572    /// assert!(res.is_err());
573    /// assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
574    /// ```
575    /// [`SubCommand`]: ./struct.SubCommand.html
576    DisableHelpSubcommand,
577
578    /// Disables `-V` and `--version` [`App`] without affecting any of the [`SubCommand`]s
579    /// (Defaults to `false`; application *does* have a version flag)
580    ///
581    /// # Examples
582    ///
583    /// ```rust
584    /// # use clap::{App, AppSettings, ErrorKind};
585    /// let res = App::new("myprog")
586    ///     .version("v1.1")
587    ///     .setting(AppSettings::DisableVersion)
588    ///     .get_matches_from_safe(vec![
589    ///         "myprog", "-V"
590    ///     ]);
591    /// assert!(res.is_err());
592    /// assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
593    /// ```
594    ///
595    /// ```rust
596    /// # use clap::{App, SubCommand, AppSettings, ErrorKind};
597    /// let res = App::new("myprog")
598    ///     .version("v1.1")
599    ///     .setting(AppSettings::DisableVersion)
600    ///     .subcommand(SubCommand::with_name("test"))
601    ///     .get_matches_from_safe(vec![
602    ///         "myprog", "test", "-V"
603    ///     ]);
604    /// assert!(res.is_err());
605    /// assert_eq!(res.unwrap_err().kind, ErrorKind::VersionDisplayed);
606    /// ```
607    /// [`SubCommand`]: ./struct.SubCommand.html
608    /// [`App`]: ./struct.App.html
609    DisableVersion,
610
611    /// Displays the arguments and [`SubCommand`]s in the help message in the order that they were
612    /// declared in, and not alphabetically which is the default.
613    ///
614    /// # Examples
615    ///
616    /// ```no_run
617    /// # use clap::{App, Arg, SubCommand, AppSettings};
618    /// App::new("myprog")
619    ///     .setting(AppSettings::DeriveDisplayOrder)
620    ///     .get_matches();
621    /// ```
622    /// [`SubCommand`]: ./struct.SubCommand.html
623    DeriveDisplayOrder,
624
625    /// Specifies to use the version of the current command for all child [`SubCommand`]s.
626    /// (Defaults to `false`; subcommands have independent version strings from their parents.)
627    ///
628    /// **NOTE:** The version for the current command **and** this setting must be set **prior** to
629    /// adding any child subcommands
630    ///
631    /// # Examples
632    ///
633    /// ```no_run
634    /// # use clap::{App, Arg, SubCommand, AppSettings};
635    /// App::new("myprog")
636    ///     .version("v1.1")
637    ///     .setting(AppSettings::GlobalVersion)
638    ///     .subcommand(SubCommand::with_name("test"))
639    ///     .get_matches();
640    /// // running `$ myprog test --version` will display
641    /// // "myprog-test v1.1"
642    /// ```
643    /// [`SubCommand`]: ./struct.SubCommand.html
644    GlobalVersion,
645
646    /// Specifies that this [`SubCommand`] should be hidden from help messages
647    ///
648    /// # Examples
649    ///
650    /// ```rust
651    /// # use clap::{App, Arg, AppSettings, SubCommand};
652    /// App::new("myprog")
653    ///     .subcommand(SubCommand::with_name("test")
654    ///     .setting(AppSettings::Hidden))
655    /// # ;
656    /// ```
657    /// [`SubCommand`]: ./struct.SubCommand.html
658    Hidden,
659
660    /// Tells `clap` *not* to print possible values when displaying help information.
661    /// This can be useful if there are many values, or they are explained elsewhere.
662    HidePossibleValuesInHelp,
663
664    /// Tries to match unknown args to partial [`subcommands`] or their [aliases]. For example to
665    /// match a subcommand named `test`, one could use `t`, `te`, `tes`, and `test`.
666    ///
667    /// **NOTE:** The match *must not* be ambiguous at all in order to succeed. i.e. to match `te`
668    /// to `test` there could not also be a subcommand or alias `temp` because both start with `te`
669    ///
670    /// **CAUTION:** This setting can interfere with [positional/free arguments], take care when
671    /// designing CLIs which allow inferred subcommands and have potential positional/free
672    /// arguments whose values could start with the same characters as subcommands. If this is the
673    /// case, it's recommended to use settings such as [`AppSeettings::ArgsNegateSubcommands`] in
674    /// conjunction with this setting.
675    ///
676    /// # Examples
677    ///
678    /// ```no_run
679    /// # use clap::{App, Arg, SubCommand, AppSettings};
680    /// let m = App::new("prog")
681    ///     .setting(AppSettings::InferSubcommands)
682    ///     .subcommand(SubCommand::with_name("test"))
683    ///     .get_matches_from(vec![
684    ///         "prog", "te"
685    ///     ]);
686    /// assert_eq!(m.subcommand_name(), Some("test"));
687    /// ```
688    /// [`subcommands`]: ./struct.SubCommand.html
689    /// [positional/free arguments]: ./struct.Arg.html#method.index
690    /// [aliases]: ./struct.App.html#method.alias
691    /// [`AppSeettings::ArgsNegateSubcommands`]: ./enum.AppSettings.html#variant.ArgsNegateSubcommands
692    InferSubcommands,
693
694    /// Specifies that the parser should not assume the first argument passed is the binary name.
695    /// This is normally the case when using a "daemon" style mode, or an interactive CLI where one
696    /// one would not normally type the binary or program name for each command.
697    ///
698    /// # Examples
699    ///
700    /// ```rust
701    /// # use clap::{App, Arg, AppSettings};
702    /// let m = App::new("myprog")
703    ///     .setting(AppSettings::NoBinaryName)
704    ///     .arg(Arg::from_usage("<cmd>... 'commands to run'"))
705    ///     .get_matches_from(vec!["command", "set"]);
706    ///
707    /// let cmds: Vec<&str> = m.values_of("cmd").unwrap().collect();
708    /// assert_eq!(cmds, ["command", "set"]);
709    /// ```
710    NoBinaryName,
711
712    /// Places the help string for all arguments on the line after the argument.
713    ///
714    /// # Examples
715    ///
716    /// ```no_run
717    /// # use clap::{App, Arg, SubCommand, AppSettings};
718    /// App::new("myprog")
719    ///     .setting(AppSettings::NextLineHelp)
720    ///     .get_matches();
721    /// ```
722    NextLineHelp,
723
724    /// **DEPRECATED**: This setting is no longer required in order to propagate values up or down
725    ///
726    /// Specifies that the parser should propagate global arg's values down or up through any *used*
727    /// child subcommands. Meaning, if a subcommand wasn't used, the values won't be propagated to
728    /// said subcommand.
729    ///
730    /// # Examples
731    ///
732    /// ```rust
733    /// # use clap::{App, Arg, AppSettings, SubCommand};
734    /// let m = App::new("myprog")
735    ///     .arg(Arg::from_usage("[cmd] 'command to run'")
736    ///         .global(true))
737    ///     .subcommand(SubCommand::with_name("foo"))
738    ///     .get_matches_from(vec!["myprog", "set", "foo"]);
739    ///
740    /// assert_eq!(m.value_of("cmd"), Some("set"));
741    ///
742    /// let sub_m = m.subcommand_matches("foo").unwrap();
743    /// assert_eq!(sub_m.value_of("cmd"), Some("set"));
744    /// ```
745    /// Now doing the same thing, but *not* using any subcommands will result in the value not being
746    /// propagated down.
747    ///
748    /// ```rust
749    /// # use clap::{App, Arg, AppSettings, SubCommand};
750    /// let m = App::new("myprog")
751    ///     .arg(Arg::from_usage("[cmd] 'command to run'")
752    ///         .global(true))
753    ///     .subcommand(SubCommand::with_name("foo"))
754    ///     .get_matches_from(vec!["myprog", "set"]);
755    ///
756    /// assert_eq!(m.value_of("cmd"), Some("set"));
757    ///
758    /// assert!(m.subcommand_matches("foo").is_none());
759    /// ```
760    #[deprecated(since = "2.27.0", note = "No longer required to propagate values")]
761    PropagateGlobalValuesDown,
762
763    /// Allows [`SubCommand`]s to override all requirements of the parent command.
764    /// For example if you had a subcommand or top level application with a required argument
765    /// that is only required as long as there is no subcommand present,
766    /// using this setting would allow you to set those arguments to [`Arg::required(true)`]
767    /// and yet receive no error so long as the user uses a valid subcommand instead.
768    ///
769    /// **NOTE:** This defaults to false (using subcommand does *not* negate requirements)
770    ///
771    /// # Examples
772    ///
773    /// This first example shows that it is an error to not use a required argument
774    ///
775    /// ```rust
776    /// # use clap::{App, Arg, AppSettings, SubCommand, ErrorKind};
777    /// let err = App::new("myprog")
778    ///     .setting(AppSettings::SubcommandsNegateReqs)
779    ///     .arg(Arg::with_name("opt").required(true))
780    ///     .subcommand(SubCommand::with_name("test"))
781    ///     .get_matches_from_safe(vec![
782    ///         "myprog"
783    ///     ]);
784    /// assert!(err.is_err());
785    /// assert_eq!(err.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
786    /// # ;
787    /// ```
788    ///
789    /// This next example shows that it is no longer error to not use a required argument if a
790    /// valid subcommand is used.
791    ///
792    /// ```rust
793    /// # use clap::{App, Arg, AppSettings, SubCommand, ErrorKind};
794    /// let noerr = App::new("myprog")
795    ///     .setting(AppSettings::SubcommandsNegateReqs)
796    ///     .arg(Arg::with_name("opt").required(true))
797    ///     .subcommand(SubCommand::with_name("test"))
798    ///     .get_matches_from_safe(vec![
799    ///         "myprog", "test"
800    ///     ]);
801    /// assert!(noerr.is_ok());
802    /// # ;
803    /// ```
804    /// [`Arg::required(true)`]: ./struct.Arg.html#method.required
805    /// [`SubCommand`]: ./struct.SubCommand.html
806    SubcommandsNegateReqs,
807
808    /// Specifies that the help text should be displayed (before exiting gracefully) if no
809    /// [`SubCommand`]s are present at runtime (i.e. an empty run such as `$ myprog`).
810    ///
811    /// **NOTE:** This should *not* be used with [`AppSettings::SubcommandRequired`] as they do
812    /// nearly same thing; this prints the help text, and the other prints an error.
813    ///
814    /// **NOTE:** If the user specifies arguments at runtime, but no subcommand the help text will
815    /// still be displayed and exit. If this is *not* the desired result, consider using
816    /// [`AppSettings::ArgRequiredElseHelp`] instead.
817    ///
818    /// # Examples
819    ///
820    /// ```rust
821    /// # use clap::{App, Arg, AppSettings};
822    /// App::new("myprog")
823    ///     .setting(AppSettings::SubcommandRequiredElseHelp)
824    /// # ;
825    /// ```
826    /// [`SubCommand`]: ./struct.SubCommand.html
827    /// [`AppSettings::SubcommandRequired`]: ./enum.AppSettings.html#variant.SubcommandRequired
828    /// [`AppSettings::ArgRequiredElseHelp`]: ./enum.AppSettings.html#variant.ArgRequiredElseHelp
829    SubcommandRequiredElseHelp,
830
831    /// Specifies that any invalid UTF-8 code points should be treated as an error and fail
832    /// with a [`ErrorKind::InvalidUtf8`] error.
833    ///
834    /// **NOTE:** This rule only applies to argument values; Things such as flags, options, and
835    /// [`SubCommand`]s themselves only allow valid UTF-8 code points.
836    ///
837    /// # Platform Specific
838    ///
839    /// Non Windows systems only
840    ///
841    /// # Examples
842    ///
843    #[cfg_attr(not(unix), doc = " ```ignore")]
844    #[cfg_attr(unix, doc = " ```")]
845    /// # use clap::{App, AppSettings, ErrorKind};
846    /// use std::ffi::OsString;
847    /// use std::os::unix::ffi::OsStringExt;
848    ///
849    /// let m = App::new("myprog")
850    ///     .setting(AppSettings::StrictUtf8)
851    ///     .arg_from_usage("<arg> 'some positional arg'")
852    ///     .get_matches_from_safe(
853    ///         vec![
854    ///             OsString::from("myprog"),
855    ///             OsString::from_vec(vec![0xe9])]);
856    ///
857    /// assert!(m.is_err());
858    /// assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidUtf8);
859    /// ```
860    /// [`SubCommand`]: ./struct.SubCommand.html
861    /// [`ErrorKind::InvalidUtf8`]: ./enum.ErrorKind.html#variant.InvalidUtf8
862    StrictUtf8,
863
864    /// Allows specifying that if no [`SubCommand`] is present at runtime,
865    /// error and exit gracefully.
866    ///
867    /// **NOTE:** This defaults to `false` (subcommands do *not* need to be present)
868    ///
869    /// # Examples
870    ///
871    /// ```rust
872    /// # use clap::{App, AppSettings, SubCommand, ErrorKind};
873    /// let err = App::new("myprog")
874    ///     .setting(AppSettings::SubcommandRequired)
875    ///     .subcommand(SubCommand::with_name("test"))
876    ///     .get_matches_from_safe(vec![
877    ///         "myprog",
878    ///     ]);
879    /// assert!(err.is_err());
880    /// assert_eq!(err.unwrap_err().kind, ErrorKind::MissingSubcommand);
881    /// # ;
882    /// ```
883    /// [`SubCommand`]: ./struct.SubCommand.html
884    SubcommandRequired,
885
886    /// Specifies that the final positional argument is a "VarArg" and that `clap` should not
887    /// attempt to parse any further args.
888    ///
889    /// The values of the trailing positional argument will contain all args from itself on.
890    ///
891    /// **NOTE:** The final positional argument **must** have [`Arg::multiple(true)`] or the usage
892    /// string equivalent.
893    ///
894    /// # Examples
895    ///
896    /// ```rust
897    /// # use clap::{App, Arg, AppSettings};
898    /// let m = App::new("myprog")
899    ///     .setting(AppSettings::TrailingVarArg)
900    ///     .arg(Arg::from_usage("<cmd>... 'commands to run'"))
901    ///     .get_matches_from(vec!["myprog", "arg1", "-r", "val1"]);
902    ///
903    /// let trail: Vec<&str> = m.values_of("cmd").unwrap().collect();
904    /// assert_eq!(trail, ["arg1", "-r", "val1"]);
905    /// ```
906    /// [`Arg::multiple(true)`]: ./struct.Arg.html#method.multiple
907    TrailingVarArg,
908
909    /// Groups flags and options together, presenting a more unified help message
910    /// (a la `getopts` or `docopt` style).
911    ///
912    /// The default is that the auto-generated help message will group flags, and options
913    /// separately.
914    ///
915    /// **NOTE:** This setting is cosmetic only and does not affect any functionality.
916    ///
917    /// # Examples
918    ///
919    /// ```no_run
920    /// # use clap::{App, Arg, SubCommand, AppSettings};
921    /// App::new("myprog")
922    ///     .setting(AppSettings::UnifiedHelpMessage)
923    ///     .get_matches();
924    /// // running `myprog --help` will display a unified "docopt" or "getopts" style help message
925    /// ```
926    UnifiedHelpMessage,
927
928    /// Disables `-V` and `--version` for all [`SubCommand`]s
929    /// (Defaults to `false`; subcommands *do* have version flags.)
930    ///
931    /// **NOTE:** This setting must be set **prior** to adding any subcommands.
932    ///
933    /// # Examples
934    ///
935    /// ```rust
936    /// # use clap::{App, SubCommand, AppSettings, ErrorKind};
937    /// let res = App::new("myprog")
938    ///     .version("v1.1")
939    ///     .setting(AppSettings::VersionlessSubcommands)
940    ///     .subcommand(SubCommand::with_name("test"))
941    ///     .get_matches_from_safe(vec![
942    ///         "myprog", "test", "-V"
943    ///     ]);
944    /// assert!(res.is_err());
945    /// assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
946    /// ```
947    /// [`SubCommand`]: ./struct.SubCommand.html
948    VersionlessSubcommands,
949
950    /// Will display a message "Press \[ENTER\]/\[RETURN\] to continue..." and wait for user before
951    /// exiting
952    ///
953    /// This is most useful when writing an application which is run from a GUI shortcut, or on
954    /// Windows where a user tries to open the binary by double-clicking instead of using the
955    /// command line.
956    ///
957    /// **NOTE:** This setting is **not** recursive with [`SubCommand`]s, meaning if you wish this
958    /// behavior for all subcommands, you must set this on each command (needing this is extremely
959    /// rare)
960    ///
961    /// # Examples
962    ///
963    /// ```rust
964    /// # use clap::{App, Arg, AppSettings};
965    /// App::new("myprog")
966    ///     .setting(AppSettings::WaitOnError)
967    /// # ;
968    /// ```
969    /// [`SubCommand`]: ./struct.SubCommand.html
970    WaitOnError,
971
972    #[doc(hidden)]
973    NeedsLongVersion,
974
975    #[doc(hidden)]
976    NeedsLongHelp,
977
978    #[doc(hidden)]
979    NeedsSubcommandHelp,
980
981    #[doc(hidden)]
982    LowIndexMultiplePositional,
983
984    #[doc(hidden)]
985    TrailingValues,
986
987    #[doc(hidden)]
988    ValidNegNumFound,
989
990    #[doc(hidden)]
991    Propagated,
992
993    #[doc(hidden)]
994    ValidArgFound,
995
996    #[doc(hidden)]
997    ContainsLast,
998}
999
1000impl FromStr for AppSettings {
1001    type Err = String;
1002    fn from_str(s: &str) -> Result<Self, <Self as FromStr>::Err> {
1003        match &*s.to_ascii_lowercase() {
1004            "disablehelpflags" => Ok(AppSettings::DisableHelpFlags),
1005            "argrequiredelsehelp" => Ok(AppSettings::ArgRequiredElseHelp),
1006            "argsnegatesubcommands" => Ok(AppSettings::ArgsNegateSubcommands),
1007            "allowinvalidutf8" => Ok(AppSettings::AllowInvalidUtf8),
1008            "allowleadinghyphen" => Ok(AppSettings::AllowLeadingHyphen),
1009            "allowexternalsubcommands" => Ok(AppSettings::AllowExternalSubcommands),
1010            "allownegativenumbers" => Ok(AppSettings::AllowNegativeNumbers),
1011            "colorauto" => Ok(AppSettings::ColorAuto),
1012            "coloralways" => Ok(AppSettings::ColorAlways),
1013            "colornever" => Ok(AppSettings::ColorNever),
1014            "coloredhelp" => Ok(AppSettings::ColoredHelp),
1015            "derivedisplayorder" => Ok(AppSettings::DeriveDisplayOrder),
1016            "dontcollapseargsinusage" => Ok(AppSettings::DontCollapseArgsInUsage),
1017            "dontdelimittrailingvalues" => Ok(AppSettings::DontDelimitTrailingValues),
1018            "disablehelpsubcommand" => Ok(AppSettings::DisableHelpSubcommand),
1019            "disableversion" => Ok(AppSettings::DisableVersion),
1020            "globalversion" => Ok(AppSettings::GlobalVersion),
1021            "hidden" => Ok(AppSettings::Hidden),
1022            "hidepossiblevaluesinhelp" => Ok(AppSettings::HidePossibleValuesInHelp),
1023            "infersubcommands" => Ok(AppSettings::InferSubcommands),
1024            "lowindexmultiplepositional" => Ok(AppSettings::LowIndexMultiplePositional),
1025            "nobinaryname" => Ok(AppSettings::NoBinaryName),
1026            "nextlinehelp" => Ok(AppSettings::NextLineHelp),
1027            "strictutf8" => Ok(AppSettings::StrictUtf8),
1028            "subcommandsnegatereqs" => Ok(AppSettings::SubcommandsNegateReqs),
1029            "subcommandrequired" => Ok(AppSettings::SubcommandRequired),
1030            "subcommandrequiredelsehelp" => Ok(AppSettings::SubcommandRequiredElseHelp),
1031            "trailingvararg" => Ok(AppSettings::TrailingVarArg),
1032            "unifiedhelpmessage" => Ok(AppSettings::UnifiedHelpMessage),
1033            "versionlesssubcommands" => Ok(AppSettings::VersionlessSubcommands),
1034            "waitonerror" => Ok(AppSettings::WaitOnError),
1035            "validnegnumfound" => Ok(AppSettings::ValidNegNumFound),
1036            "validargfound" => Ok(AppSettings::ValidArgFound),
1037            "propagated" => Ok(AppSettings::Propagated),
1038            "trailingvalues" => Ok(AppSettings::TrailingValues),
1039            _ => Err("unknown AppSetting, cannot convert from str".to_owned()),
1040        }
1041    }
1042}
1043
1044#[cfg(test)]
1045mod test {
1046    use super::AppSettings;
1047
1048    #[test]
1049    fn app_settings_fromstr() {
1050        assert_eq!(
1051            "disablehelpflags".parse::<AppSettings>().unwrap(),
1052            AppSettings::DisableHelpFlags
1053        );
1054        assert_eq!(
1055            "argsnegatesubcommands".parse::<AppSettings>().unwrap(),
1056            AppSettings::ArgsNegateSubcommands
1057        );
1058        assert_eq!(
1059            "argrequiredelsehelp".parse::<AppSettings>().unwrap(),
1060            AppSettings::ArgRequiredElseHelp
1061        );
1062        assert_eq!(
1063            "allowexternalsubcommands".parse::<AppSettings>().unwrap(),
1064            AppSettings::AllowExternalSubcommands
1065        );
1066        assert_eq!(
1067            "allowinvalidutf8".parse::<AppSettings>().unwrap(),
1068            AppSettings::AllowInvalidUtf8
1069        );
1070        assert_eq!(
1071            "allowleadinghyphen".parse::<AppSettings>().unwrap(),
1072            AppSettings::AllowLeadingHyphen
1073        );
1074        assert_eq!(
1075            "allownegativenumbers".parse::<AppSettings>().unwrap(),
1076            AppSettings::AllowNegativeNumbers
1077        );
1078        assert_eq!(
1079            "coloredhelp".parse::<AppSettings>().unwrap(),
1080            AppSettings::ColoredHelp
1081        );
1082        assert_eq!(
1083            "colorauto".parse::<AppSettings>().unwrap(),
1084            AppSettings::ColorAuto
1085        );
1086        assert_eq!(
1087            "coloralways".parse::<AppSettings>().unwrap(),
1088            AppSettings::ColorAlways
1089        );
1090        assert_eq!(
1091            "colornever".parse::<AppSettings>().unwrap(),
1092            AppSettings::ColorNever
1093        );
1094        assert_eq!(
1095            "disablehelpsubcommand".parse::<AppSettings>().unwrap(),
1096            AppSettings::DisableHelpSubcommand
1097        );
1098        assert_eq!(
1099            "disableversion".parse::<AppSettings>().unwrap(),
1100            AppSettings::DisableVersion
1101        );
1102        assert_eq!(
1103            "dontcollapseargsinusage".parse::<AppSettings>().unwrap(),
1104            AppSettings::DontCollapseArgsInUsage
1105        );
1106        assert_eq!(
1107            "dontdelimittrailingvalues".parse::<AppSettings>().unwrap(),
1108            AppSettings::DontDelimitTrailingValues
1109        );
1110        assert_eq!(
1111            "derivedisplayorder".parse::<AppSettings>().unwrap(),
1112            AppSettings::DeriveDisplayOrder
1113        );
1114        assert_eq!(
1115            "globalversion".parse::<AppSettings>().unwrap(),
1116            AppSettings::GlobalVersion
1117        );
1118        assert_eq!(
1119            "hidden".parse::<AppSettings>().unwrap(),
1120            AppSettings::Hidden
1121        );
1122        assert_eq!(
1123            "hidepossiblevaluesinhelp".parse::<AppSettings>().unwrap(),
1124            AppSettings::HidePossibleValuesInHelp
1125        );
1126        assert_eq!(
1127            "lowindexmultiplePositional".parse::<AppSettings>().unwrap(),
1128            AppSettings::LowIndexMultiplePositional
1129        );
1130        assert_eq!(
1131            "nobinaryname".parse::<AppSettings>().unwrap(),
1132            AppSettings::NoBinaryName
1133        );
1134        assert_eq!(
1135            "nextlinehelp".parse::<AppSettings>().unwrap(),
1136            AppSettings::NextLineHelp
1137        );
1138        assert_eq!(
1139            "subcommandsnegatereqs".parse::<AppSettings>().unwrap(),
1140            AppSettings::SubcommandsNegateReqs
1141        );
1142        assert_eq!(
1143            "subcommandrequired".parse::<AppSettings>().unwrap(),
1144            AppSettings::SubcommandRequired
1145        );
1146        assert_eq!(
1147            "subcommandrequiredelsehelp".parse::<AppSettings>().unwrap(),
1148            AppSettings::SubcommandRequiredElseHelp
1149        );
1150        assert_eq!(
1151            "strictutf8".parse::<AppSettings>().unwrap(),
1152            AppSettings::StrictUtf8
1153        );
1154        assert_eq!(
1155            "trailingvararg".parse::<AppSettings>().unwrap(),
1156            AppSettings::TrailingVarArg
1157        );
1158        assert_eq!(
1159            "unifiedhelpmessage".parse::<AppSettings>().unwrap(),
1160            AppSettings::UnifiedHelpMessage
1161        );
1162        assert_eq!(
1163            "versionlesssubcommands".parse::<AppSettings>().unwrap(),
1164            AppSettings::VersionlessSubcommands
1165        );
1166        assert_eq!(
1167            "waitonerror".parse::<AppSettings>().unwrap(),
1168            AppSettings::WaitOnError
1169        );
1170        assert_eq!(
1171            "validnegnumfound".parse::<AppSettings>().unwrap(),
1172            AppSettings::ValidNegNumFound
1173        );
1174        assert_eq!(
1175            "validargfound".parse::<AppSettings>().unwrap(),
1176            AppSettings::ValidArgFound
1177        );
1178        assert_eq!(
1179            "propagated".parse::<AppSettings>().unwrap(),
1180            AppSettings::Propagated
1181        );
1182        assert_eq!(
1183            "trailingvalues".parse::<AppSettings>().unwrap(),
1184            AppSettings::TrailingValues
1185        );
1186        assert_eq!(
1187            "infersubcommands".parse::<AppSettings>().unwrap(),
1188            AppSettings::InferSubcommands
1189        );
1190        assert!("hahahaha".parse::<AppSettings>().is_err());
1191    }
1192}