When using boost::program_options
, how do I set the name of an argument for boost::program_options::value<>()
?
#include
daminetreg's answer works, but it can be a little verbose when used for lots of option entries. I just hacked together an overload for the value
template to construct my value_sematic
s with an additional value_name
: using
template
typed_value*
value(T* v, const char * value_typename)
{
typed_value* r = new typed_value(v);
r->value_name( value_typename );
return r;
}
you can create and add a new program_option like this:
int width;
desc.add_options()
("width", boost::program_options::value( &width, "NUM"),
"Give width");
(Note: this doesn't address all the other construction templates, especially not the default value()
constructor that the OP wants to use)