This is what I do for automatically printing positional options:
void printUsage(const std::string &argv0)
{
std::ostream &os = std::cout;
os << "Usage:" << std::endl;
// print only basename of argv[0]
boost::filesystem::path p(argv0);
os << " " << p.filename().string();
os << " [options]";
std::string last = "";
int rep = 0;
for(int i = 0; i < positional_options_description_.max_total_count(); i++)
{
const std::string &n = positional_options_description_.name_for_position(i);
if(n == last)
{
if(!rep) os << " ...";
if(rep++ > 1000) break;
}
else
{
os << " " << n;
last = n;
rep = 0;
}
}
os << std::endl << std::endl;
os << options_description_ << std::endl;
}
The logic for checking repeated argument names is needed only if you have repeated options that can repeat an infinite number of times, i.e. with count equal to -1, otherwise you can simplify this a little bit, e.g. replace the if... else if ...
with os << " " << n;
.
With current (1.68) version of boost, there is no way of telling if an option description is positional or not, so there is nothing to do to improve the help, for example, excluding positional options from being printed.