...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::program_options::command_line_style::style_t
// In header: <boost/program_options/cmdline.hpp> enum style_t { allow_long = = 1, allow_short = = allow_long << 1, allow_dash_for_short = = allow_short << 1, allow_slash_for_short = = allow_dash_for_short << 1, long_allow_adjacent = = allow_slash_for_short << 1, long_allow_next = = long_allow_adjacent << 1, short_allow_adjacent = = long_allow_next << 1, short_allow_next = = short_allow_adjacent << 1, allow_sticky = = short_allow_next << 1, allow_guessing = = allow_sticky << 1, long_case_insensitive = = allow_guessing << 1, short_case_insensitive = = long_case_insensitive << 1, case_insensitive = = (long_case_insensitive | short_case_insensitive), allow_long_disguise = = short_case_insensitive << 1, unix_style = = (allow_short | short_allow_adjacent | short_allow_next | allow_long | long_allow_adjacent | long_allow_next | allow_sticky | allow_guessing | allow_dash_for_short), default_style = = unix_style };
Various possible styles of options.
There are "long" options, which start with "--" and "short", which start with either "-" or "/". Both kinds can be allowed or disallowed, see allow_long and allow_short. The allowed character for short options is also configurable.
Option's value can be specified in the same token as name ("--foo=bar"), or in the next token.
It's possible to introduce long options by the same character as short options, see allow_long_disguise.
Finally, guessing (specifying only prefix of option) and case insensitive processing are supported.
allow_long
allow_short
allow_dash_for_short
allow_slash_for_short
long_allow_adjacent
Allow option parameter in the same token for long option, like in --foo=10
long_allow_next
Allow option parameter in the next token for long options.
short_allow_adjacent
Allow option parameter in the same token for short options.
short_allow_next
Allow option parameter in the next token for short options.
allow_sticky
Allow to merge several short options together, so that "-s -k" become "-sk". All of the options but last should accept no parameter. For example, if "-s" accept a parameter, then "k" will be taken as parameter, not another short option. Dos-style short options cannot be sticky.
allow_guessing
Allow abbreviated spellings for long options, if they unambiguously identify long option. No long option name should be prefix of other long option name if guessing is in effect.
long_case_insensitive
Ignore the difference in case for long options.
short_case_insensitive
Ignore the difference in case for short options.
case_insensitive
Ignore the difference in case for all options.
allow_long_disguise
Allow long options with single option starting character, e.g -foo=10
unix_style
The more-or-less traditional unix style.
default_style
The default style.