@@ -119,6 +119,11 @@ class ArgParser {
119
119
///
120
120
/// If [hide] is `true` , this option won't be included in [usage] .
121
121
///
122
+ /// If [hideNegatedUsage] is `true` , the fact that this flag can be negated
123
+ /// will not be documented in [usage] .
124
+ /// It is an error for [hideNegatedUsage] to be `true` if [negatable] is
125
+ /// `false` .
126
+ ///
122
127
/// If [aliases] is provided, these are used as aliases for [name] . These
123
128
/// aliases will not appear as keys in the [options] map.
124
129
///
@@ -133,6 +138,7 @@ class ArgParser {
133
138
bool negatable = true ,
134
139
void Function (bool )? callback,
135
140
bool hide = false ,
141
+ bool hideNegatedUsage = false ,
136
142
List <String > aliases = const []}) {
137
143
_addOption (
138
144
name,
@@ -146,6 +152,7 @@ class ArgParser {
146
152
OptionType .flag,
147
153
negatable: negatable,
148
154
hide: hide,
155
+ hideNegatedUsage: hideNegatedUsage,
149
156
aliases: aliases);
150
157
}
151
158
@@ -285,6 +292,7 @@ class ArgParser {
285
292
bool ? splitCommas,
286
293
bool mandatory = false ,
287
294
bool hide = false ,
295
+ bool hideNegatedUsage = false ,
288
296
List <String > aliases = const []}) {
289
297
var allNames = [name, ...aliases];
290
298
if (allNames.any ((name) => findByNameOrAlias (name) != null )) {
@@ -306,12 +314,20 @@ class ArgParser {
306
314
'The option $name cannot be mandatory and have a default value.' );
307
315
}
308
316
317
+ if (! negatable && hideNegatedUsage) {
318
+ throw ArgumentError (
319
+ 'The option $name cannot have `hideNegatedUsage` '
320
+ 'without being negatable.' ,
321
+ );
322
+ }
323
+
309
324
var option = newOption (name, abbr, help, valueHelp, allowed, allowedHelp,
310
325
defaultsTo, callback, type,
311
326
negatable: negatable,
312
327
splitCommas: splitCommas,
313
328
mandatory: mandatory,
314
329
hide: hide,
330
+ hideNegatedUsage: hideNegatedUsage,
315
331
aliases: aliases);
316
332
_options[name] = option;
317
333
_optionsAndSeparators.add (option);
0 commit comments