Boost logo

Boost Users :

From: Steven Mackenzie (boost_at_[hidden])
Date: 2007-07-19 04:25:51


Niko Vuokko wrote:

> multiple_tokens: For example a string option -E could be given like this:
>
> program -E stuff more_stuff even_more_stuff -- file

Niko, Others, Thanks for your descriptions, they were very helpful, as was the
discussion generated.

It seems like zero_tokens and multiple_tokens can't be mixed?

I would like to define a command line syntax like this

./prog --export
        --export name.bin binary
        --export "another name.txt" text transposed
        --etc

where --export can occour multiple times as above, with between 0 and 3 parameters.

If --export appears with no arguments then the export action is performed, but
with no output to disk; if it has arguments then they should either be parsed in
to a custom structure, or vector<string>.

So I suppose one definition of the export option would be

struct ExportConfig
{
        enum FileFmt { TEXT, BINARY, };

        string name;
        FileFmt format;
        bool isTransposed;
};

desc.add_options()
    ("export",
        po::value< vector < ExportConfig > >(),
            "Export data for processing, with output to the named disk file")
    ;

I understand that allowing the zero argument version of --export is conceptually
difficult, but if I split that option out as --exportNoFile, could I use
program_options to parse the remaining 1 - 3 argument version?

Steven


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