I have a CLI implemented using structopt
. I would like to have an optional flag which defaults to some value that can be overridden, or switched off completely. For example
prog # x = Some(3)
prog -x 4 # x = Some(4)
prog -x no # x = None
This hopefully illustrates that
- x = 3 by default
- the default can be overridden
- the option can be switched off
The use of no
as the switch-off token, is just an example: any convenient to type marker would do.
Can you suggest a clean way of implementing this in structopt
?