Subject: [Boost-bugs] [Boost C++ Libraries] #3330: boost::program_options doesn't allow naming the argument in a straightforward way
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-08-10 13:08:47
#3330: boost::program_options doesn't allow naming the argument in a
straightforward way
------------------------------+---------------------------------------------
Reporter: grumbel@⦠| Owner: vladimir_prus
Type: Feature Requests | Status: new
Milestone: Boost 1.40.0 | Component: program_options
Version: Boost 1.37.0 | Severity: Problem
Keywords: |
------------------------------+---------------------------------------------
When using boost::program_options, there is no straightforward way to set
the name of a boost::program_options::value<>():
{{{
#include <iostream>
#include <boost/program_options.hpp>
int main()
{
boost::program_options::options_description desc;
desc.add_options()
("width", boost::program_options::value<int>(),
"Give width");
std::cout << desc << std::endl;
return 0;
}
}}}
The above code gives:
{{{
--width arg Give width in pixels
}}}
What it should allow is replacing the "arg" name with something more
descriptive like PIXELS:
{{{
--width PIXELS Give width in pixels
}}}
For example via {{{boost::program_options::value<int>("PIXELS")}}}.
Even the tutorial makes "use" of this non-existant feature:
http://www.boost.org/doc/libs/1_39_0/doc/html/program_options/tutorial.html
The output at the bottom of the page shows "--optimization n" instead of "
--optimization arg", same with "path".
There is a way to accomplish a different arg name by inheriting from
boost::program_options::typed_value<> as documented at:
http://stackoverflow.com/questions/1249646/when-using-boostprogramoptions-
how-does-one-set-the-name-of-the-argument
But considering that naming the argument is a extremely common use case,
this should be doable in a much more straightforward manner, such as an
additional name argument to po_value().
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/3330> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:01 UTC