Debian Codegraph @

debian/rust-vendor/clap_builder/src/builder/app_settings.rs

raw
1 #[allow(unused)]
2 use crate::Arg;
3 #[allow(unused)]
4 use crate::Command;
5
6 #[derive(Default, Copy, Clone, Debug, PartialEq, Eq)]
7 pub(crate) struct AppFlags(u32);
8
9 impl 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
27 impl 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(Debug, PartialEq, Copy, Clone)]
47 #[repr(u8)]
48 pub(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
84 impl AppSettings {
85 fn bit(self) -> u32 {
86 1 << (self as u8)
87 }
88 }