[cli-users] unset option

Boris Kolpackov boris at codesynthesis.com
Thu Dec 1 07:49:15 EST 2011


Hi Philipp,

Philipp Eichmann <philipp.eichmann at gmail.com> writes:

> std::string -d | --directory  {
>     "<text>",
>     "bla"
>   };
> 
> std::string -z  {
>     "<text>",
>     "blu"
>   };
> 
> If I launch the application with "./myapp -d -z test" and print option
> -d with options.d(), I get the string "-z" as result.
> Which is obivously wrong since -d should not be set or empty.

CLI supports two types of options: those that have a value and those
that don't (called flags). In particular, ODB does not support options
that may or may not have a value.

To define a flag, use bool as the option type:

bool -z
{
  "do zzz"
};

std::string -d
{
  "<dir>"
  "specify directory"
};

With the above option specification, you can do:

./myapp -z -d foo
./myapp -d foo -z

Boris



More information about the cli-users mailing list