Boost Program Options: Just curiosity, why double dashes ?
I am studying Boost Program Options library and I am curious, why was it choosen double dashes as the token to identify an option in the command line ? Example: my_program --help Would not a single dash be enough and less verbose ? What is the rationale behind that ? Thanks, -- Mauricio Gomes "Think globally, act locally".
Hi!
This is POSIX standard.
Regards,
Ovanes
On Fri, Nov 27, 2009 at 7:12 PM, Mauricio Gomes
I am studying Boost Program Options library and I am curious, why was it choosen double dashes as the token to identify an option in the command line ?
Example: my_program --help
Would not a single dash be enough and less verbose ? What is the rationale behind that ?
Thanks, -- Mauricio Gomes "Think globally, act locally".
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Mauricio Gomes wrote:
I am studying Boost Program Options library and I am curious, why was it choosen double dashes as the token to identify an option in the command line ?
Example: my_program --help
Would not a single dash be enough and less verbose ? What is the rationale behind that ?
Actually, it's the default style. See cmdline.hpp for a wide array of tweaks you can apply. The default style, actually, is the Unix style. It seems reasonable to borrow the default style from an operating system family that is known for fairly developed tradition of command line usage. - Volodya
The reasons given are sufficient but perhaps not as informative as they could have been. The "old way" is a single dash with single-letter options. When multiple options are given it is conventional to accept them all strung together after one dash. So ls -lrt means the same thing as ls -l -r -t In some cases, optional parameters were introduced using a dash, a letter, and then a symbol or file name (fragment) as in cc -lm foo.c where the "m" is the name of a library (the math funcitons of the standard C library). So when you've run out of letters or gotten tired of explaining the ones that don't make sense and you want to go to words or phrases as options, what do you do? The answer chosen to that question is that we double the dashes. -swn
Mauricio Gomes wrote:
I am studying Boost Program Options library and I am curious, why was it choosen double dashes as the token to identify an option in the command line ?
Example: my_program --help
Would not a single dash be enough and less verbose ? What is the rationale behind that ?
POSIX recommends that a) options are preceded by a single dash b) that multiple options may follow the dash c) the options may come in any order In particular this implies the following would be equivalent: -h -e -l -p -help If one wishes to use long option names with a single dash only, one may encounter conflicts in determining what the option string means if some combination of one-letter options matches a long name of a particular option. Hence GNU then extended the POSIX conventions by requiring long option names to be preceded by two dashes. --> Mika Heiskanen
participants (5)
-
Mauricio Gomes
-
Mika Heiskanen
-
Ovanes Markarian
-
Stephen Nuchia
-
Vladimir Prus