Closed sd-trailhead-james closed 5 years ago
This is a bit confusing, but you have to use default_value
. the switch
command won’t complain about unknown flags, so it happily accepts default
, even though it’s not recognized.
Thanks, @davetron5000! That was indeed all it was.
Let's say I have a global
:verbose
switch. I want it to have a default value oftrue
so that the app operates in verbose mode by default. Users can then specify--no-verbose
to disable/decrease verbosity.I have attempted to represent that desired behavior with the following code, but the default value for the switch is
false
. Running the app without the switch results infalse
. Running it with--verbose
results intrue
, and running it with--no-verbose
results infalse
. So when the switch is present, the behavior is as desired, but I can't get the default value oftrue
to work as desired. How can I get the switch to betrue
by default when the user omits the switch?