Skip to main content

clap_builder/builder/
app_settings.rs

1#[allow(unused)]
2use crate::Arg;
3#[allow(unused)]
4use crate::Command;
5
6#[derive(#[automatically_derived]impl ::core::default::Default for AppFlags {
    #[inline]
    fn default() -> Self { AppFlags(::core::default::Default::default()) }
}Default, #[automatically_derived]impl ::core::marker::Copy for AppFlags { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for AppFlags {
}
#[automatically_derived]impl ::core::clone::Clone for AppFlags {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<u32>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for AppFlags {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "AppFlags",
            &&self.0)
    }
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for AppFlags
    {
}
#[automatically_derived]impl ::core::cmp::PartialEq for AppFlags {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for AppFlags {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<u32>;
    }
}Eq)]
7pub(crate) struct AppFlags(u32);
8
9impl AppFlags {
10    pub(crate) fn set(&mut self, setting: AppSettings) {
11        self.0 |= setting.bit();
12    }
13
14    pub(crate) fn unset(&mut self, setting: AppSettings) {
15        self.0 &= !setting.bit();
16    }
17
18    pub(crate) fn is_set(&self, setting: AppSettings) -> bool {
19        self.0 & setting.bit() != 0
20    }
21
22    pub(crate) fn insert(&mut self, other: Self) {
23        self.0 |= other.0;
24    }
25}
26
27impl std::ops::BitOr for AppFlags {
28    type Output = Self;
29
30    fn bitor(mut self, rhs: Self) -> Self::Output {
31        self.insert(rhs);
32        self
33    }
34}
35
36/// Application level settings, which affect how [`Command`] operates
37///
38/// <div class="warning">
39///
40/// **NOTE:** When these settings are used, they apply only to current command, and are *not*
41/// propagated down or up through child or parent subcommands
42///
43/// </div>
44///
45/// [`Command`]: crate::Command
46#[derive(#[automatically_derived]impl ::core::fmt::Debug for AppSettings {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_c_like_enum_write_str(f,
            "IgnoreErrors AllowHyphenValues AllowNegativeNumbers AllArgsOverrideSelf AllowMissingPositional TrailingVarArg DontDelimitTrailingValues InferLongArgs InferSubcommands SubcommandRequired AllowExternalSubcommands Multicall SubcommandsNegateReqs ArgsNegateSubcommands SubcommandPrecedenceOverArg FlattenHelp ArgRequiredElseHelp NextLineHelp DisableColoredHelp DisableHelpFlag DisableHelpSubcommand DisableVersionFlag PropagateVersion Hidden HidePossibleValues HelpExpected NoBinaryName ColorAuto ColorAlways ColorNever Built BinNameBuilt",
            match self {
                AppSettings::IgnoreErrors => 0usize,
                AppSettings::AllowHyphenValues => 13usize,
                AppSettings::AllowNegativeNumbers => 31usize,
                AppSettings::AllArgsOverrideSelf => 52usize,
                AppSettings::AllowMissingPositional => 72usize,
                AppSettings::TrailingVarArg => 95usize,
                AppSettings::DontDelimitTrailingValues => 110usize,
                AppSettings::InferLongArgs => 136usize,
                AppSettings::InferSubcommands => 150usize,
                AppSettings::SubcommandRequired => 167usize,
                AppSettings::AllowExternalSubcommands => 186usize,
                AppSettings::Multicall => 211usize,
                AppSettings::SubcommandsNegateReqs => 221usize,
                AppSettings::ArgsNegateSubcommands => 243usize,
                AppSettings::SubcommandPrecedenceOverArg => 265usize,
                AppSettings::FlattenHelp => 293usize,
                AppSettings::ArgRequiredElseHelp => 305usize,
                AppSettings::NextLineHelp => 325usize,
                AppSettings::DisableColoredHelp => 338usize,
                AppSettings::DisableHelpFlag => 357usize,
                AppSettings::DisableHelpSubcommand => 373usize,
                AppSettings::DisableVersionFlag => 395usize,
                AppSettings::PropagateVersion => 414usize,
                AppSettings::Hidden => 431usize,
                AppSettings::HidePossibleValues => 438usize,
                AppSettings::HelpExpected => 457usize,
                AppSettings::NoBinaryName => 470usize,
                AppSettings::ColorAuto => 483usize,
                AppSettings::ColorAlways => 493usize,
                AppSettings::ColorNever => 505usize,
                AppSettings::Built => 516usize,
                AppSettings::BinNameBuilt => 522usize,
            })
    }
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    AppSettings {
}
#[automatically_derived]impl ::core::cmp::PartialEq for AppSettings {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]impl ::core::marker::Copy for AppSettings { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for AppSettings {
}
#[automatically_derived]impl ::core::clone::Clone for AppSettings {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone)]
47#[repr(u8)]
48pub(crate) enum AppSettings {
49    IgnoreErrors,
50    AllowHyphenValues,
51    AllowNegativeNumbers,
52    AllArgsOverrideSelf,
53    AllowMissingPositional,
54    TrailingVarArg,
55    DontDelimitTrailingValues,
56    InferLongArgs,
57    InferSubcommands,
58    SubcommandRequired,
59    AllowExternalSubcommands,
60    Multicall,
61    SubcommandsNegateReqs,
62    ArgsNegateSubcommands,
63    SubcommandPrecedenceOverArg,
64    FlattenHelp,
65    ArgRequiredElseHelp,
66    NextLineHelp,
67    DisableColoredHelp,
68    DisableHelpFlag,
69    DisableHelpSubcommand,
70    DisableVersionFlag,
71    PropagateVersion,
72    Hidden,
73    HidePossibleValues,
74    HelpExpected,
75    NoBinaryName,
76    #[allow(dead_code)]
77    ColorAuto,
78    ColorAlways,
79    ColorNever,
80    Built,
81    BinNameBuilt,
82}
83
84impl AppSettings {
85    fn bit(self) -> u32 {
86        1 << (self as u8)
87    }
88}