summaryrefslogtreecommitdiffstats
path: root/vendor/clap_builder/src/builder/app_settings.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/clap_builder/src/builder/app_settings.rs')
-rw-r--r--vendor/clap_builder/src/builder/app_settings.rs147
1 files changed, 29 insertions, 118 deletions
diff --git a/vendor/clap_builder/src/builder/app_settings.rs b/vendor/clap_builder/src/builder/app_settings.rs
index 7a9ff8c69..4fce4b4a2 100644
--- a/vendor/clap_builder/src/builder/app_settings.rs
+++ b/vendor/clap_builder/src/builder/app_settings.rs
@@ -1,21 +1,35 @@
-// Std
-use std::ops::BitOr;
-
#[allow(unused)]
use crate::Arg;
#[allow(unused)]
use crate::Command;
-// Third party
-use bitflags::bitflags;
+#[derive(Default, Copy, Clone, Debug, PartialEq, Eq)]
+pub(crate) struct AppFlags(u32);
+
+impl AppFlags {
+ pub(crate) fn set(&mut self, setting: AppSettings) {
+ self.0 |= setting.bit();
+ }
+
+ pub(crate) fn unset(&mut self, setting: AppSettings) {
+ self.0 &= !setting.bit();
+ }
+
+ pub(crate) fn is_set(&self, setting: AppSettings) -> bool {
+ self.0 & setting.bit() != 0
+ }
+
+ pub(crate) fn insert(&mut self, other: Self) {
+ self.0 |= other.0;
+ }
+}
-#[doc(hidden)]
-#[derive(Debug, Copy, Clone, PartialEq, Eq)]
-pub(crate) struct AppFlags(Flags);
+impl std::ops::BitOr for AppFlags {
+ type Output = Self;
-impl Default for AppFlags {
- fn default() -> Self {
- AppFlags(Flags::COLOR_AUTO)
+ fn bitor(mut self, rhs: Self) -> Self::Output {
+ self.insert(rhs);
+ self
}
}
@@ -26,7 +40,7 @@ impl Default for AppFlags {
///
/// [`Command`]: crate::Command
#[derive(Debug, PartialEq, Copy, Clone)]
-#[non_exhaustive]
+#[repr(u8)]
pub(crate) enum AppSettings {
IgnoreErrors,
AllowHyphenValues,
@@ -62,111 +76,8 @@ pub(crate) enum AppSettings {
BinNameBuilt,
}
-bitflags! {
- struct Flags: u64 {
- const SC_NEGATE_REQS = 1;
- const SC_REQUIRED = 1 << 1;
- const ARG_REQUIRED_ELSE_HELP = 1 << 2;
- const PROPAGATE_VERSION = 1 << 3;
- const DISABLE_VERSION_FOR_SC = 1 << 4;
- const WAIT_ON_ERROR = 1 << 6;
- const DISABLE_VERSION_FLAG = 1 << 10;
- const HIDDEN = 1 << 11;
- const TRAILING_VARARG = 1 << 12;
- const NO_BIN_NAME = 1 << 13;
- const ALLOW_UNK_SC = 1 << 14;
- const LEADING_HYPHEN = 1 << 16;
- const NO_POS_VALUES = 1 << 17;
- const NEXT_LINE_HELP = 1 << 18;
- const DISABLE_COLORED_HELP = 1 << 20;
- const COLOR_ALWAYS = 1 << 21;
- const COLOR_AUTO = 1 << 22;
- const COLOR_NEVER = 1 << 23;
- const DONT_DELIM_TRAIL = 1 << 24;
- const ALLOW_NEG_NUMS = 1 << 25;
- const DISABLE_HELP_SC = 1 << 27;
- const ARGS_NEGATE_SCS = 1 << 29;
- const PROPAGATE_VALS_DOWN = 1 << 30;
- const ALLOW_MISSING_POS = 1 << 31;
- const TRAILING_VALUES = 1 << 32;
- const BUILT = 1 << 33;
- const BIN_NAME_BUILT = 1 << 34;
- const VALID_ARG_FOUND = 1 << 35;
- const INFER_SUBCOMMANDS = 1 << 36;
- const CONTAINS_LAST = 1 << 37;
- const ARGS_OVERRIDE_SELF = 1 << 38;
- const HELP_REQUIRED = 1 << 39;
- const SUBCOMMAND_PRECEDENCE_OVER_ARG = 1 << 40;
- const DISABLE_HELP_FLAG = 1 << 41;
- const INFER_LONG_ARGS = 1 << 43;
- const IGNORE_ERRORS = 1 << 44;
- const MULTICALL = 1 << 45;
- const EXPAND_HELP_SUBCOMMAND_TREES = 1 << 46;
- const NO_OP = 0;
+impl AppSettings {
+ fn bit(self) -> u32 {
+ 1 << (self as u8)
}
}
-
-impl_settings! { AppSettings, AppFlags,
- ArgRequiredElseHelp
- => Flags::ARG_REQUIRED_ELSE_HELP,
- SubcommandPrecedenceOverArg
- => Flags::SUBCOMMAND_PRECEDENCE_OVER_ARG,
- ArgsNegateSubcommands
- => Flags::ARGS_NEGATE_SCS,
- AllowExternalSubcommands
- => Flags::ALLOW_UNK_SC,
- AllowHyphenValues
- => Flags::LEADING_HYPHEN,
- AllowNegativeNumbers
- => Flags::ALLOW_NEG_NUMS,
- AllowMissingPositional
- => Flags::ALLOW_MISSING_POS,
- ColorAlways
- => Flags::COLOR_ALWAYS,
- ColorAuto
- => Flags::COLOR_AUTO,
- ColorNever
- => Flags::COLOR_NEVER,
- DontDelimitTrailingValues
- => Flags::DONT_DELIM_TRAIL,
- DisableColoredHelp
- => Flags::DISABLE_COLORED_HELP,
- DisableHelpSubcommand
- => Flags::DISABLE_HELP_SC,
- DisableHelpFlag
- => Flags::DISABLE_HELP_FLAG,
- DisableVersionFlag
- => Flags::DISABLE_VERSION_FLAG,
- PropagateVersion
- => Flags::PROPAGATE_VERSION,
- HidePossibleValues
- => Flags::NO_POS_VALUES,
- HelpExpected
- => Flags::HELP_REQUIRED,
- Hidden
- => Flags::HIDDEN,
- Multicall
- => Flags::MULTICALL,
- NoBinaryName
- => Flags::NO_BIN_NAME,
- SubcommandsNegateReqs
- => Flags::SC_NEGATE_REQS,
- SubcommandRequired
- => Flags::SC_REQUIRED,
- TrailingVarArg
- => Flags::TRAILING_VARARG,
- NextLineHelp
- => Flags::NEXT_LINE_HELP,
- IgnoreErrors
- => Flags::IGNORE_ERRORS,
- Built
- => Flags::BUILT,
- BinNameBuilt
- => Flags::BIN_NAME_BUILT,
- InferSubcommands
- => Flags::INFER_SUBCOMMANDS,
- AllArgsOverrideSelf
- => Flags::ARGS_OVERRIDE_SELF,
- InferLongArgs
- => Flags::INFER_LONG_ARGS
-}