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