program_options: How to best model two/three pos args
Hello, my application has positional arguments like that: Run tests : ./app test ConfigurationName PathToSrc Run server : ./app server ParticipantName ConfigurationName Print XML reference: ./app xml Linewidth It has three (if first in [test, server]) or two (if first in [xml]) positional arguments. How to model and test this best using boost? I could add three options and declare them as positional arguments, named like "first", "second", "third". I could also use just one positional argument like: po::positional_options_description pos_dec; pos_dec.add("positionals", 3); and test the resulting vector. What do you think? Thanks, Florian
On 10/08/2014 11:30 AM, Florian Lindner wrote:
Hello,
my application has positional arguments like that:
Run tests : ./app test ConfigurationName PathToSrc Run server : ./app server ParticipantName ConfigurationName Print XML reference: ./app xml Linewidth
It has three (if first in [test, server]) or two (if first in [xml]) positional arguments.
How to model and test this best using boost?
I could add three options and declare them as positional arguments, named like "first", "second", "third".
I could also use just one positional argument like:
po::positional_options_description pos_dec; pos_dec.add("positionals", 3);
and test the resulting vector.
What do you think?
Frorian, it appears that here, these positional options are not parsed, just passed through to other code, so handling them as vector, like your third approach would, is easiest. - Volodya
participants (2)
-
Florian Lindner
-
Vladimir Prus