Search code examples
c++boostboost-program-options

option '--opt' cannot be specified more than once


Running into an error from boost program options. I am running a command such as prog --opt arg1 --opt arg2.

It returns this error

option '--opt' cannot be specified more than once.

Is there a way to use the option name more than once?

Currently I have the program option defined as such and it has no default value. I am interested in figuring out a way to specify the use of the option name several times

po::value<std::string>()

Solution

  • From http://www.radmangames.com/programming/how-to-use-boost-program_options:

    Specify an option that can be specified multiple times

    --option <value1> --option <value2> --option <value3>

    ("option", po::value<std::vector<arg_type> >(), "a list of values")