Skip to content

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

Description

@IsabelMarleen

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions