cxxopts icon indicating copy to clipboard operation
cxxopts copied to clipboard

When a default string is an empty string, it shows without quotes in help

Open piotrklos-tcl opened this issue 5 years ago • 4 comments

When I define a default argument to an option like this:

      ("c,config", "a json config, as a string", cxxopts::value<string>()->default_value(""))

it shows in the help like this:

-c, --config arg       a json config, as a string (default: )

This is ambiguous because the user won't know if the default is an empty string or if there is no default. It should look like this:

-c, --config arg       a json config, as a string (default: "")

piotrklos-tcl avatar Aug 09 '19 12:08 piotrklos-tcl

try default_value("\"\""); escaped quotes

rathod-sahaab avatar Aug 20 '19 06:08 rathod-sahaab

@piotrklos-tcl That seems reasonable. @rathod-sahaab That would set the default value to actually be the string "", which is probably not what is needed.

jarro2783 avatar Aug 20 '19 06:08 jarro2783

@jarro2783 I get it now 😅 Need to edit one of help()

rathod-sahaab avatar Aug 20 '19 11:08 rathod-sahaab

I am trying to figure out if there is a way to ALWAYS get the default value quoted? Some of my default values are space separated strings, and it would be much clearer if they were always quoted.

TheQue42 avatar May 12 '22 08:05 TheQue42