boostorg / boostorg/program_options

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

Open
#115 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
136
Forks
117
PR merge metrics
No merged PRs in 30d

Description

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
namespace po = boost::program_options;

po::options_description description("General options");
description.add_options()
("key", po::value()->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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.