@@ -3,32 +3,33 @@ use std::ascii::AsciiExt;
3
3
4
4
bitflags ! {
5
5
flags Flags : u32 {
6
- const SC_NEGATE_REQS = 0b00000000000000000000000001 ,
7
- const SC_REQUIRED = 0b00000000000000000000000010 ,
8
- const A_REQUIRED_ELSE_HELP = 0b00000000000000000000000100 ,
9
- const GLOBAL_VERSION = 0b00000000000000000000001000 ,
10
- const VERSIONLESS_SC = 0b00000000000000000000010000 ,
11
- const UNIFIED_HELP = 0b00000000000000000000100000 ,
12
- const WAIT_ON_ERROR = 0b00000000000000000001000000 ,
13
- const SC_REQUIRED_ELSE_HELP = 0b00000000000000000010000000 ,
14
- const NEEDS_LONG_HELP = 0b00000000000000000100000000 ,
15
- const NEEDS_LONG_VERSION = 0b00000000000000001000000000 ,
16
- const NEEDS_SC_HELP = 0b00000000000000010000000000 ,
17
- const DISABLE_VERSION = 0b00000000000000100000000000 ,
18
- const HIDDEN = 0b00000000000001000000000000 ,
19
- const TRAILING_VARARG = 0b00000000000010000000000000 ,
20
- const NO_BIN_NAME = 0b00000000000100000000000000 ,
21
- const ALLOW_UNK_SC = 0b00000000001000000000000000 ,
22
- const UTF8_STRICT = 0b00000000010000000000000000 ,
23
- const UTF8_NONE = 0b00000000100000000000000000 ,
24
- const LEADING_HYPHEN = 0b00000001000000000000000000 ,
25
- const NO_POS_VALUES = 0b00000010000000000000000000 ,
26
- const NEXT_LINE_HELP = 0b00000100000000000000000000 ,
27
- const DERIVE_DISP_ORDER = 0b00001000000000000000000000 ,
28
- const COLORED_HELP = 0b00010000000000000000000000 ,
29
- const COLOR_ALWAYS = 0b00100000000000000000000000 ,
30
- const COLOR_AUTO = 0b01000000000000000000000000 ,
31
- const COLOR_NEVER = 0b10000000000000000000000000 ,
6
+ const SC_NEGATE_REQS = 0b000000000000000000000000001 ,
7
+ const SC_REQUIRED = 0b000000000000000000000000010 ,
8
+ const A_REQUIRED_ELSE_HELP = 0b000000000000000000000000100 ,
9
+ const GLOBAL_VERSION = 0b000000000000000000000001000 ,
10
+ const VERSIONLESS_SC = 0b000000000000000000000010000 ,
11
+ const UNIFIED_HELP = 0b000000000000000000000100000 ,
12
+ const WAIT_ON_ERROR = 0b000000000000000000001000000 ,
13
+ const SC_REQUIRED_ELSE_HELP = 0b000000000000000000010000000 ,
14
+ const NEEDS_LONG_HELP = 0b000000000000000000100000000 ,
15
+ const NEEDS_LONG_VERSION = 0b000000000000000001000000000 ,
16
+ const NEEDS_SC_HELP = 0b000000000000000010000000000 ,
17
+ const DISABLE_VERSION = 0b000000000000000100000000000 ,
18
+ const HIDDEN = 0b000000000000001000000000000 ,
19
+ const TRAILING_VARARG = 0b000000000000010000000000000 ,
20
+ const NO_BIN_NAME = 0b000000000000100000000000000 ,
21
+ const ALLOW_UNK_SC = 0b000000000001000000000000000 ,
22
+ const UTF8_STRICT = 0b000000000010000000000000000 ,
23
+ const UTF8_NONE = 0b000000000100000000000000000 ,
24
+ const LEADING_HYPHEN = 0b000000001000000000000000000 ,
25
+ const NO_POS_VALUES = 0b000000010000000000000000000 ,
26
+ const NEXT_LINE_HELP = 0b000000100000000000000000000 ,
27
+ const DERIVE_DISP_ORDER = 0b000001000000000000000000000 ,
28
+ const COLORED_HELP = 0b000010000000000000000000000 ,
29
+ const COLOR_ALWAYS = 0b000100000000000000000000000 ,
30
+ const COLOR_AUTO = 0b001000000000000000000000000 ,
31
+ const COLOR_NEVER = 0b010000000000000000000000000 ,
32
+ const DONT_DELIM_TRAIL = 0b100000000000000000000000000 ,
32
33
}
33
34
}
34
35
@@ -79,7 +80,8 @@ impl AppFlags {
79
80
DeriveDisplayOrder => DERIVE_DISP_ORDER ,
80
81
ColorAlways => COLOR_ALWAYS ,
81
82
ColorAuto => COLOR_AUTO ,
82
- ColorNever => COLOR_NEVER
83
+ ColorNever => COLOR_NEVER ,
84
+ DontDelimitTrailingValues => DONT_DELIM_TRAIL
83
85
}
84
86
}
85
87
@@ -551,6 +553,24 @@ pub enum AppSettings {
551
553
/// .get_matches();
552
554
/// ```
553
555
ColorNever ,
556
+ /// Disables the automatic delimiting of values when `--` or [`AppSettings::TrailingVarArg`]
557
+ /// was used.
558
+ ///
559
+ /// **NOTE:** The same thing can be done manually by setting the final positional argument to
560
+ /// [`Arg::use_delimiter(false)`]. Using this setting is safer, because it's easier to locate
561
+ /// when making changes.
562
+ ///
563
+ /// # Examples
564
+ ///
565
+ /// ```no_run
566
+ /// # use clap::{App, Arg, SubCommand, AppSettings};
567
+ /// App::new("myprog")
568
+ /// .setting(AppSettings::DontDelimitTrailingValues)
569
+ /// .get_matches();
570
+ /// ```
571
+ /// [`AppSettings::TrailingVarArg`]: ./enum.AppSettings.html#variant.TrailingVarArg
572
+ /// [`Arg::use_delimiter(false)`]: ./struct.Arg.html#method.use_delimiter
573
+ DontDelimitTrailingValues ,
554
574
#[ doc( hidden) ]
555
575
NeedsLongVersion ,
556
576
#[ doc( hidden) ]
@@ -633,6 +653,8 @@ mod test {
633
653
AppSettings :: ColoredHelp ) ;
634
654
assert_eq ! ( "hidden" . parse:: <AppSettings >( ) . unwrap( ) ,
635
655
AppSettings :: Hidden ) ;
656
+ assert_eq ! ( "dontdelimittrailingvalues" . parse:: <AppSettings >( ) . unwrap( ) ,
657
+ AppSettings :: DontDelimitTrailingValues ) ;
636
658
assert ! ( "hahahaha" . parse:: <AppSettings >( ) . is_err( ) ) ;
637
659
}
638
660
}
0 commit comments