Boost logo

Boost Users :

Subject: [Boost-users] Program Options.. Specifying "-e" as an option value.....
From: david.weber_at_[hidden]
Date: 2010-10-07 18:19:50


I have an application, which spawns off other applications. As input,
it takes in environment variables and arguments to pass to the resultant
application. For instance:

 

 

mutate -E "env_var1=val" -a "." ls

 

This will run:

 

ls .

 

and the environment will only have "env_var1" equal to "val"

 

 

So. Something funny comes along when I try to pass "-e" as an argument.

 

So, in the above would be:

 

mutate -a "-e" -a "foo" xterm

 

The program options parser attempts to parse the "-e", and says "I don't
know what it is".

 

Any thoughts on having it skip that option?

 

 

Code Snippits:

 

 

    po::options_description visible("Program options. Usage %1%");

    visible.add_options()

        ("env,E", po::value<string_vector_t>(), "Specify an environment
variable to run the executable with. In the form of foo=bar")

        ("arg,a", po::value<string_vector_t>(), "Specify a command line
argument to pass to the executable")

    ;

 

    // Set up some hidden options

    po::options_description hidden("Hidden options");

    hidden.add_options()

        ("executable", po::value < std::string>(), "the executable to
run")

    ;

 

    // Set up positional arguments. They are going to be execute

    po::positional_options_description pos;

    pos.add("executable", 1); // There can only be 1 item executed

 

    // Consolidate all the options into a single one

    po::options_description all_options("All Options");

    all_options.add(visible);

    all_options.add(hidden);

 

    // Parse the command line options

    po::store(po::command_line_parser(argc,
argv).options(all_options).positional(pos).run(), vm);

    po::notify(vm);



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