Commit c51b8bbdee7d37c3305fa6bc373024c2e6f2250f

Authored by Jarryd Beck
1 parent abab8ce3

default and implicit options in readme

This closes issue #20.
Showing 1 changed file with 18 additions and 0 deletions
README.md
... ... @@ -64,6 +64,24 @@ To set up positional arguments, call
64 64 where "last" should be the name of an option with a container type, and the
65 65 others should have a single value.
66 66  
  67 +## Default and implicit values
  68 +
  69 +An option can be declared with a default or an implicit value, or both.
  70 +
  71 +A default value is the value that an option takes when it is not specified
  72 +on the command line. The following specifies a default value for an option:
  73 +
  74 + cxxopts::value<std::string>()->default_value("value")
  75 +
  76 +An implicit value is the value that an option takes when it is given on the
  77 +command line without an argument. The following specifies an implicit value:
  78 +
  79 + cxxopts::value<std::string>()->implicit_value("implicit")
  80 +
  81 +If an option had both, then not specifying it would give the value `"value"`,
  82 +writing it on the command line as `--option` would give the value `"implicit"`,
  83 +and writing `--option=another` would give it the value `"another"`.
  84 +
67 85 # Linking
68 86  
69 87 This is a header only library.
... ...