Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2007-10-17 11:21:39


Joe Gottman wrote:

>
> I recently used the program_options library for the first time and
> found it very useful. However, there's one easily implemented feature
> that's missing: the ability to set the name of a parameter that's
> associated with a particular option. In the first example in the
> tutorial we have the code
>
> po::options_description desc("Allowed options");
> desc.add_options()
> ("help", "produce help message")
> ("compression", po::value<int>(), "set compression level")
> ;
>
> When desc is then sent to cout, the output then looks like
>
> Allowed options:
> --help : produce help message
> --compression arg : set compression level
>
>
> But suppose we wanted the name of the parameter associated with the
> --compression option to be something other than arg.

I intentionally did not add that bit of flexibility, as I though that
configurable 'arg' is not adding all that much to legibility. Do you have
some concrete examples?

> If this function were included, then the code above could be rewritten as
>
> po::options_description desc("Allowed options");
> desc.add_options()
> ("help", "produce help message")
> ("compression", po::value<int>()->argument_name("level-number"),
> "set compression level")
> ;
>
> and then the output would be
>
> Allowed options:
> --help : produce help message
> --compression level-number : set compression level

Well, here, I don't like the duplication between 'level' and 'level-number'
Maybe it would be cleaner to have just:

  --compression arg : set compression level (0-9)

or some such?

- Volodya


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk