Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supplying a list of possible values instead of a default value to an option? #115

Open
IsabelMarleen opened this issue Feb 14, 2022 · 0 comments

Comments

@IsabelMarleen
Copy link

Is there a way to specify a restricted list of values a command line option can take? I was thinking of something like this:

#include <boost/program_options.hpp>
namespace po = boost::program_options;

po::options_description description("General options");
description.add_options()
       ("key", po::value<string>()->possible_values("a", "b", "c"), "description of key");

Running executable --key d in the command line would throw an error but executable --key a would not. I know there is the option of manually processing the argument supplied to the key later on, but I was wondering if the functionality of identifying unambiguous abbreviations could be utilised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant