Boost logo

Boost Users :

Subject: Re: [Boost-users] Program Options.. Specifying "-e" as an option value.....
From: Diederick C. Niehorster (dcnieho_at_[hidden])
Date: 2010-10-07 21:17:08


I don't know too much about the library, but see that i your code you
use a capital E. See if there is a way to turn on
case-insensitiveness, or change it to what you want it to be.

Best,
Dee

On Fri, Oct 8, 2010 at 06:19, <david.weber_at_[hidden]> wrote:
> 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 mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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