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

Feature request: built-int choices arguments support. #277

Closed
KindRoach opened this issue Jul 23, 2023 · 2 comments
Closed

Feature request: built-int choices arguments support. #277

KindRoach opened this issue Jul 23, 2023 · 2 comments

Comments

@KindRoach
Copy link

To restrict the set of values for an argument, a custom action is needed as the example in README.md:

program.add_argument("input")
  .default_value(std::string{"baz"})
  .action([](const std::string& value) {
    static const std::vector<std::string> choices = { "foo", "bar", "baz" };
    if (std::find(choices.begin(), choices.end(), value) != choices.end()) {
      return value;
    }
    return std::string{ "baz" };
  });

Built-int choices arguments support will be more convenient, such like:

program.add_argument("input")
  .default_value(std::string{"baz"})
  .choices("foo", "bar", "baz");

Thanks!

@TheFGFSEagle
Copy link

Is this going to be implemented any time soon ? Can I be of any help ?

@TheFGFSEagle
Copy link

Thanks ! :)

russkel pushed a commit to Greenroom-Robotics/argparse that referenced this issue Dec 11, 2023
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

2 participants