@@ -4,21 +4,22 @@ use std::str::FromStr;
4
4
5
5
bitflags ! {
6
6
flags Flags : u16 {
7
- const REQUIRED = 1 << 0 ,
8
- const MULTIPLE = 1 << 1 ,
9
- const EMPTY_VALS = 1 << 2 ,
10
- const GLOBAL = 1 << 3 ,
11
- const HIDDEN = 1 << 4 ,
12
- const TAKES_VAL = 1 << 5 ,
13
- const USE_DELIM = 1 << 6 ,
14
- const NEXT_LINE_HELP = 1 << 7 ,
15
- const R_UNLESS_ALL = 1 << 8 ,
16
- const REQ_DELIM = 1 << 9 ,
17
- const DELIM_NOT_SET = 1 << 10 ,
18
- const HIDE_POS_VALS = 1 << 11 ,
19
- const ALLOW_TAC_VALS = 1 << 12 ,
20
- const REQUIRE_EQUALS = 1 << 13 ,
21
- const LAST = 1 << 14 ,
7
+ const REQUIRED = 1 << 0 ,
8
+ const MULTIPLE = 1 << 1 ,
9
+ const EMPTY_VALS = 1 << 2 ,
10
+ const GLOBAL = 1 << 3 ,
11
+ const HIDDEN = 1 << 4 ,
12
+ const TAKES_VAL = 1 << 5 ,
13
+ const USE_DELIM = 1 << 6 ,
14
+ const NEXT_LINE_HELP = 1 << 7 ,
15
+ const R_UNLESS_ALL = 1 << 8 ,
16
+ const REQ_DELIM = 1 << 9 ,
17
+ const DELIM_NOT_SET = 1 << 10 ,
18
+ const HIDE_POS_VALS = 1 << 11 ,
19
+ const ALLOW_TAC_VALS = 1 << 12 ,
20
+ const REQUIRE_EQUALS = 1 << 13 ,
21
+ const LAST = 1 << 14 ,
22
+ const HIDE_DEFAULT_VAL = 1 << 15 ,
22
23
}
23
24
}
24
25
@@ -44,7 +45,8 @@ impl ArgFlags {
44
45
HidePossibleValues => HIDE_POS_VALS ,
45
46
AllowLeadingHyphen => ALLOW_TAC_VALS ,
46
47
RequireEquals => REQUIRE_EQUALS ,
47
- Last => LAST
48
+ Last => LAST ,
49
+ HideDefaultValue => HIDE_DEFAULT_VAL
48
50
}
49
51
}
50
52
@@ -87,6 +89,8 @@ pub enum ArgSettings {
87
89
/// Specifies that the arg is the last positional argument and may be accessed early via `--`
88
90
/// syntax
89
91
Last ,
92
+ /// Hides the default value from the help string
93
+ HideDefaultValue ,
90
94
#[ doc( hidden) ]
91
95
RequiredUnlessAll ,
92
96
#[ doc( hidden) ]
@@ -112,6 +116,7 @@ impl FromStr for ArgSettings {
112
116
"allowleadinghyphen" => Ok ( ArgSettings :: AllowLeadingHyphen ) ,
113
117
"requireequals" => Ok ( ArgSettings :: RequireEquals ) ,
114
118
"last" => Ok ( ArgSettings :: Last ) ,
119
+ "hidedefaultvalue" => Ok ( ArgSettings :: HideDefaultValue ) ,
115
120
_ => Err ( "unknown ArgSetting, cannot convert from str" . to_owned ( ) ) ,
116
121
}
117
122
}
@@ -153,6 +158,8 @@ mod test {
153
158
ArgSettings :: RequireEquals ) ;
154
159
assert_eq ! ( "last" . parse:: <ArgSettings >( ) . unwrap( ) ,
155
160
ArgSettings :: Last ) ;
161
+ assert_eq ! ( "hidedefaultvalue" . parse:: <ArgSettings >( ) . unwrap( ) ,
162
+ ArgSettings :: HideDefaultValue ) ;
156
163
assert ! ( "hahahaha" . parse:: <ArgSettings >( ) . is_err( ) ) ;
157
164
}
158
165
}
0 commit comments