ABu
ABu

Reputation: 12279

Boost program options: positional and multitoken options

How does boost::program_options parse or manage an input when both multitoken and positional options are allowed?

For example:

./app.sample pos1 --multitokenoption a b c d pos2 

How does boost know when a multitokenoption finishes and a positional option begins?

Obviously, the most logical allowed behaviour would be that a multitoken option must be present as last parameter, just as happens with default arguments in function parameters, but the documentation says nothing about it.

Upvotes: 5

Views: 3430

Answers (1)

HEKTO
HEKTO

Reputation: 4191

There are three way to mark the end of values for a multitoken option:

  1. Another option:

        ./app.sample pos1 --multitokenoption a b c d --regularoption v pos2
    
  2. Option name for the positional option (almost the #1):

        ./app.sample pos1 --multitokenoption a b c d --pos2 pos2
    
  3. Double-dash:

        ./app.sample pos1 --multitokenoption a b c d -- pos2
    

Otherwise the multi-token option won't know where to stop - nothing magical.

Upvotes: 6

Related Questions