Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 931
Peregring-lk Avatar asked May 22 '14 19:05

Peregring-lk


1 Answers

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.

like image 126
HEKTO Avatar answered Sep 30 '22 00:09

HEKTO