#6114 closed Patches (fixed)
Program options help message do not align across multiple groups
Reported by: | Owned by: | Vladimir Prus | |
---|---|---|---|
Milestone: | To Be Determined | Component: | program_options |
Version: | Boost 1.47.0 | Severity: | Problem |
Keywords: | Program options help description | Cc: |
Description
libs/program_options/src/options_description.cpp contains code to line up the description strings if the length of the options column > 23.
However, this does not take different groups into account. The patch gets the column lengths from the subgroups as well.
Current situation:
Overall: Option group 1: --opt1 Short option 1 --option 2 Short option 2 ^ Aligned here Option group 2: --much_longer_option arg Misaligned description in 2nd group if option column length > magic 23 character limit ^ Aligned here
Patched:
Overall: Option group 1: --opt1 Short option 1 --option 2 Short option 2 ^ Aligned here Option group 2: --much_longer_option arg Misaligned description in 2nd group if option column length > magic 23 character limit ^ Aligned here
is produced by this minimal program
#include <iostream> #include <boost/program_options.hpp> namespace po = boost::program_options; int main (int argc, char *argv[]) { // 1st group po::options_description groups1 ("Option group 1"); groups1.add_options() ("opt1", "Short option 1") ("option 2", "Short option 2\n^\nAligned here"); // 2nd group po::options_description groups2 ("Option group 2"); groups2.add_options() ("much_longer_option", po::value<int>(), "Misaligned description in 2nd group if option " "column length > magic 23 character limit\n^\n" "Aligned here"); po::options_description cmdline_args("Overall"); cmdline_args.add(groups1); cmdline_args.add(groups2); std::cerr << cmdline_args << "\n"; return 0; }
Attachments (2)
Change History (7)
by , 11 years ago
comment:1 by , 10 years ago
This "bug" seems to be still present on boost 1.49.0. It would be great if this patch could be checked / pushed by someone. It's not a major issue to have unaligned options but still, it would looks much better if they were.
comment:2 by , 9 years ago
I would also really appreciate someone qualified assessing this relatively simple patch because this issue is making my Boost.Program_options (1.54.0) interface look much less professional. Thanks very much.
comment:3 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:4 by , 9 years ago
I've checked in to trunk, sorry it took so long, and also for missing 1.55 release.
I've set a reminder to merge to release branch, although I don't know what that would mean in the git world, but hopefully will figure out.
test case