docopt.cpp icon indicating copy to clipboard operation
docopt.cpp copied to clipboard

How do I set up the options to take optional values?

Open FrankDMartinez opened this issue 9 years ago • 6 comments

I might not quite understand the documentation correctly but, suppose I want to set a certain quality to a default level if an option is not passed to the application, a different default value if the option is passed with no arguments, and a third value if the option is passed with certain arguments?

FrankDMartinez avatar Aug 02 '16 21:08 FrankDMartinez

I dont think this is possible because I'm not sure how you would express that in documentation in a way that is understandable to the docopt algorithm. Do you have any ideas?

jaredgrubb avatar Nov 14 '16 17:11 jaredgrubb

Not immediately, no. That's why I asked.

FrankDMartinez avatar May 09 '17 13:05 FrankDMartinez

I think #72 is talking about the same feature request and mentions an example

janwilmans avatar Jul 17 '17 18:07 janwilmans

maybe like this? [default: (.*), implicit: (.*)] (in the Options:  block)

isometriq avatar Sep 12 '17 21:09 isometriq

I would like validation too: https://github.com/docopt/docopt.cpp/issues/86

isometriq avatar Sep 12 '17 21:09 isometriq

Maybe like this ?

Options:
--always_set=[<n>]     This has the current behaviour  [default: 10].
--always_set           This implicitly sets the value to 5 [value: 5]

janwilmans avatar Sep 13 '17 10:09 janwilmans