
Hi there, I cannot get the short option name feature to work. For some reason an exception is being thrown when I use the short name. I'm using boost 1.34 on MSVC 8. Here is what I'm doing: #include <boost\program_options.hpp> using namespace std; using namespace boost; namespace po = boost::program_options; int main( int argc, char* argv[] ) { string input; po::options_description settings( "" ); settings.add_options() ( "input,I" , po::value< string >( &input ) ->default_value( "" ) , "" ); po::options_description options; options.add( settings ); po::variables_map variables; store( parse_command_line( argc , argv , settings ) , variables ); notify( variables ); cout << input << endl; return 0; } Using --input="hello" works but not -I="hello". What am I overlooking? Thanks ahead, Christian

Christian Henning wrote:
Using --input="hello" works but not -I="hello". What am I overlooking?
The thing is that in no command line style I know, you can use short option together with "=". Can you try -I "hello" or -Ihello ? Note that if guessing is allowed, then: --i="hello" will work (provided you have no other options starting with "i"). - Volodya

Hi Vladimir, OK I got it. Was obviously my fault. Thanks for your quick reply. A short overview of things I've tested. -I "hello" // works -I"hello" // works --i="hello" // works ----> Why small letters? --I="hello" // doesn't work. On 7/16/07, Vladimir Prus <ghost@cs.msu.su> wrote:
Christian Henning wrote:
Using --input="hello" works but not -I="hello". What am I overlooking?
The thing is that in no command line style I know, you can use short option together with "=". Can you try
-I "hello"
or
-Ihello
? Note that if guessing is allowed, then:
--i="hello"
will work (provided you have no other options starting with "i").
- Volodya
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi Vladimir, I'm a bit confused. Why does the following short option name not work: #include <boost\program_options.hpp> using namespace std; using namespace boost; namespace po = boost::program_options; int main( int argc, char* argv[] ) { string input; po::options_description settings( "" ); settings.add_options() ( "input_1,I1" , po::value< string >( &input ) ->default_value( "" ) , "" ); po::options_description options; options.add( settings ); po::variables_map variables; store( parse_command_line( argc , argv , settings ) , variables ); notify( variables ); cout << input << endl; return 0; } -I1"hello" wont work? In my project I have two input files. The long names are input_1 and input_2. It seems to me I cannot have numbers in the short version like: -I1"hello" -I2"world". Any ideas? Christian

"Christian Henning" writes:
-I1"hello" wont work? In my project I have two input files. The long names are input_1 and input_2. It seems to me I cannot have numbers in the short version like: -I1"hello" -I2"world".
Hi, I believe short options must be exactly one character. Thats the meaning of "short option" in most contexts. I'm guessing, but to support parsing '-I1', you'll probably have to follow the guidelines for "Non-conventional Syntax" that are part the manual. Making it synonymous with --input_1 is another problem. -Bryan
participants (3)
-
Bryan Green
-
Christian Henning
-
Vladimir Prus