Boost logo

Boost Users :

Subject: [Boost-users] [program_options] word-wrapping broken in presence of default arguments
From: Peter Simons (simons_at_[hidden])
Date: 2008-12-12 13:48:00


Hi,

in Boost 1.37.0, this program

  #include <iostream>
  #include <string>
  #include <boost/program_options.hpp>

  int main(int argc, char * argv[])
  {
    using namespace std;
    using namespace boost::program_options;
    options_description cmdline_options("Supported options");
    cmdline_options.add_options()
      ("help", "this is a sufficiently long text to require word-wrapping")
      ("prefix", value<string>()->default_value("/h/proj/tmp/dispatch"), "root path of the dispatch installation")
      ;
    cerr << cmdline_options << endl;
    return 0;
  }

displays a usage message that looks weird:

 $ g++ foo.cpp -lboost_program_options.a && ./a.out
 | Supported options:
 | --help this is a sufficiently long text to requ
 | ire word-wrapping
 | --prefix arg (=/h/proj/tmp/dispatch) root path of the dispatch installation

It appears that the word-wrapping algorithm can't handle the default
argument properly. Is that a known problem? Can I work around that
somehow?

I also wonder whether it's possible to format the help string such that
it's printed in the *next line*, like this:

 | --prefix arg (=/ridiculously/long/path/that/leaves/no/room/on/right/side)
 | root path of the dispatch installation

I tried adding a '\n' at the beginning of the help string, but that
didn't have the desired effect. Is there any way to accomplish this?

Take care,
Peter


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net