Boost logo

Boost Users :

Subject: [Boost-users] [Program_options] How to parse a command-line incrementally
From: Olaf Meeuwissen (olaf.meeuwissen_at_[hidden])
Date: 2012-02-14 20:49:46

Hi all,

I'm looking to implement an "incremental" command-line parser using

The parser should be incremental in the sense that parsing should stop
at the first unknown option or positional argument. At this point, my
program would pick the next options description and continue parsing
with that. This would proceed until the command-line has been parsed
completely or the program is no longer interested in the remainder.

The idea is to use this for a program that interfaces to a collection of
commands that each support a set of actions. The program, commands and
actions all have their own list of options, so you get command-lines
like so

  prog [prog-opts] [cmd [cmd-opts] [act [act-opts]]]

Eventually, I might want to throw in positional arguments for some or
each of these as well.

Any suggestions on how to achieve this? My main concerns are with the
way Boost.Program_options wants to parse the whole command-line (when
using allow_unregistered()) every time and with how to keep track of
what still needs to be processed.

Thanks in advance,

Olaf Meeuwissen, LPIC-2           FLOSS Engineer -- AVASYS CORPORATION
FSF Associate Member #1962               Help support software freedom

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at