Default Flag values - Documentation Doubt

In the documentation Using flag inversions, enumerations, and counts

The following is mentioned:

Since these flags are non-optional and don't have default values, they're now required when calling the command. The specified prefixes are prepended to the long names for the flags:

% example --index --enable-required-element
true true
% example --no-index --disable-required-element
false false


  1. When I tried without specifying the boolean flags they seem to work as shown below:
% example
false false

Not sure this was a typo, I have made the correction in my fork, could raise a PR if relevant.

Thanks @somu — the documentation was incorrect on that point. Flags with inversions let you specify a default value, and if you pass nil, then the flag is required. I've updated the documentation section you linked to.


@nnnnnnnn Thanks a lot for the updating the documentation, nice explanation.

I didn't realise you could pass an optional (nil) for the default value to make it a required field.

1 Like