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() -> AppFlags { AppFlags(::core::default::Default::default()) }
}Default, #[automatically_derived]
impl ::core::marker::Copy for AppFlags { }Copy, #[automatically_derived]
impl ::core::clone::Clone for AppFlags {
    #[inline]
    fn clone(&self) -> AppFlags {
        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::cmp::PartialEq for AppFlags {
    #[inline]
    fn eq(&self, other: &AppFlags) -> 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 {
        static __NAMES: &str =
            "IgnoreErrorsAllowHyphenValuesAllowNegativeNumbersAllArgsOverrideSelfAllowMissingPositionalTrailingVarArgDontDelimitTrailingValuesInferLongArgsInferSubcommandsSubcommandRequiredAllowExternalSubcommandsMulticallSubcommandsNegateReqsArgsNegateSubcommandsSubcommandPrecedenceOverArgFlattenHelpArgRequiredElseHelpNextLineHelpDisableColoredHelpDisableHelpFlagDisableHelpSubcommandDisableVersionFlagPropagateVersionHiddenHidePossibleValuesHelpExpectedNoBinaryNameColorAutoColorAlwaysColorNeverBuiltBinNameBuilt";
        static __OFFSET: [usize; 33] =
            [0usize, 12usize, 29usize, 49usize, 68usize, 90usize, 104usize,
                    129usize, 142usize, 158usize, 176usize, 200usize, 209usize,
                    230usize, 251usize, 278usize, 289usize, 308usize, 320usize,
                    338usize, 353usize, 374usize, 392usize, 408usize, 414usize,
                    432usize, 444usize, 456usize, 465usize, 476usize, 486usize,
                    491usize, 503usize];
        let __d = ::core::intrinsics::discriminant_value(self) as usize;
        ::core::fmt::Formatter::debug_c_like_enum_write_str(f, __NAMES,
            &__OFFSET, __d)
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for AppSettings {
    #[inline]
    fn eq(&self, other: &AppSettings) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::marker::Copy for AppSettings { }Copy, #[automatically_derived]
impl ::core::clone::Clone for AppSettings {
    #[inline]
    fn clone(&self) -> AppSettings { *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}