@@ -119,6 +119,10 @@ 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 will
123+ /// not be documented in [usage] .
124+ /// It is an error for [hideNegatedUsage] to be `true` if [negatable] is `false` .
125+ ///
122126 /// If [aliases] is provided, these are used as aliases for [name] . These
123127 /// aliases will not appear as keys in the [options] map.
124128 ///
@@ -133,6 +137,7 @@ class ArgParser {
133137 bool negatable = true ,
134138 void Function (bool )? callback,
135139 bool hide = false ,
140+ bool hideNegatedUsage = false ,
136141 List <String > aliases = const []}) {
137142 _addOption (
138143 name,
@@ -146,6 +151,7 @@ class ArgParser {
146151 OptionType .flag,
147152 negatable: negatable,
148153 hide: hide,
154+ hideNegatedUsage: hideNegatedUsage,
149155 aliases: aliases);
150156 }
151157
@@ -285,6 +291,7 @@ class ArgParser {
285291 bool ? splitCommas,
286292 bool mandatory = false ,
287293 bool hide = false ,
294+ bool hideNegatedUsage = false ,
288295 List <String > aliases = const []}) {
289296 var allNames = [name, ...aliases];
290297 if (allNames.any ((name) => findByNameOrAlias (name) != null )) {
@@ -306,12 +313,19 @@ class ArgParser {
306313 'The option $name cannot be mandatory and have a default value.' );
307314 }
308315
316+ if (! negatable && hideNegatedUsage) {
317+ throw ArgumentError (
318+ 'The option $name cannot have `hideNegatedUsage` without being negatable.' ,
319+ );
320+ }
321+
309322 var option = newOption (name, abbr, help, valueHelp, allowed, allowedHelp,
310323 defaultsTo, callback, type,
311324 negatable: negatable,
312325 splitCommas: splitCommas,
313326 mandatory: mandatory,
314327 hide: hide,
328+ hideNegatedUsage: hideNegatedUsage,
315329 aliases: aliases);
316330 _options[name] = option;
317331 _optionsAndSeparators.add (option);
0 commit comments