@@ -119,6 +119,11 @@ class ArgParser {
119119 ///
120120 /// If [hide] is `true` , this option won't be included in [usage] .
121121 ///
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+ ///
122127 /// If [aliases] is provided, these are used as aliases for [name] . These
123128 /// aliases will not appear as keys in the [options] map.
124129 ///
@@ -133,6 +138,7 @@ class ArgParser {
133138 bool negatable = true ,
134139 void Function (bool )? callback,
135140 bool hide = false ,
141+ bool hideNegatedUsage = false ,
136142 List <String > aliases = const []}) {
137143 _addOption (
138144 name,
@@ -146,6 +152,7 @@ class ArgParser {
146152 OptionType .flag,
147153 negatable: negatable,
148154 hide: hide,
155+ hideNegatedUsage: hideNegatedUsage,
149156 aliases: aliases);
150157 }
151158
@@ -285,6 +292,7 @@ class ArgParser {
285292 bool ? splitCommas,
286293 bool mandatory = false ,
287294 bool hide = false ,
295+ bool hideNegatedUsage = false ,
288296 List <String > aliases = const []}) {
289297 var allNames = [name, ...aliases];
290298 if (allNames.any ((name) => findByNameOrAlias (name) != null )) {
@@ -306,12 +314,20 @@ class ArgParser {
306314 'The option $name cannot be mandatory and have a default value.' );
307315 }
308316
317+ if (! negatable && hideNegatedUsage) {
318+ throw ArgumentError (
319+ 'The option $name cannot have `hideNegatedUsage` '
320+ 'without being negatable.' ,
321+ );
322+ }
323+
309324 var option = newOption (name, abbr, help, valueHelp, allowed, allowedHelp,
310325 defaultsTo, callback, type,
311326 negatable: negatable,
312327 splitCommas: splitCommas,
313328 mandatory: mandatory,
314329 hide: hide,
330+ hideNegatedUsage: hideNegatedUsage,
315331 aliases: aliases);
316332 _options[name] = option;
317333 _optionsAndSeparators.add (option);
0 commit comments