program_options hierarchical options
Is there an example of using program_options to build a hierarchical options parser (a la svn, apt-get, git, etc.), in which earlier options select parsers for later options? -- Yang Zhang http://www.mit.edu/~y_z/
Yang Zhang wrote:
Is there an example of using program_options to build a hierarchical options parser (a la svn, apt-get, git, etc.), in which earlier options select parsers for later options?
SVN option parsing do not, in fact, select parsers for later options. There's a single global set of options, it's just the first positional token that is taken to mean 'command', and for each command, and additional check is performed that only options that are relevant for that command are specified. Such check has to be done manually with the current version of program_options -- but does not seem a hard thing to do. - Volodya
On Mon, Nov 9, 2009 at 12:00 AM, Vladimir Prus
Yang Zhang wrote:
Is there an example of using program_options to build a hierarchical options parser (a la svn, apt-get, git, etc.), in which earlier options select parsers for later options?
SVN option parsing do not, in fact, select parsers for later options. There's a single global set of options, it's just the first positional token that is taken to mean 'command', and for each command, and additional check is performed that only options that are relevant for that command are specified. Such check has to be done manually with the current version of program_options -- but does not seem a hard thing to do.
Then forget svn and consider git. I was just pulling an arbitrary example; the particular example wasn't the focus. The question remains. -- Yang Zhang http://www.mit.edu/~y_z/
Yang Zhang wrote:
On Mon, Nov 9, 2009 at 12:00 AM, Vladimir Prus
wrote: Yang Zhang wrote:
Is there an example of using program_options to build a hierarchical options parser (a la svn, apt-get, git, etc.), in which earlier options select parsers for later options?
SVN option parsing do not, in fact, select parsers for later options. There's a single global set of options, it's just the first positional token that is taken to mean 'command', and for each command, and additional check is performed that only options that are relevant for that command are specified. Such check has to be done manually with the current version of program_options -- but does not seem a hard thing to do.
Then forget svn and consider git.
<rant> I am afraid I dislike git enough to be unable to see any sense it its interface -- even if some is there. </rant>
I was just pulling an arbitrary example; the particular example wasn't the focus. The question remains.
The answer is that while you can create multiple option_descriptions objects, look at the first token on the command line, and then pick an suitable object from that, it must be done by hand. - Volodya
participants (2)
-
Vladimir Prus
-
Yang Zhang