I would just like to allow my user to specify the verbosity level by using multiple times the flag -v
or --verbose
. For instance:
foobar -v
: verbosity level is 1foobar
: verbosity level is 0foobar -vvv
: verbosity level is 3
My current setting is:
po::options_description desc("Options for this program");
desc.add_options()
("verbose,v", "Turn on verbose mode")
...
;
po::variables_map opts;
po::store(po::parse_command_line(argc, argv, desc), opts);
po::notify(opts);
const int verbosity = opts.count("verbose"); // Can be 0 or 1
How should I modify this code so to allow verbosity to be greater than 1?
(Of course I could allow an option like -v 2
, but I prefer -vv
in this case, which is quite common.)