boostorg / boostorg/program_options

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

Offen
#115 0 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C++
Sterne
136
Forks
117
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne damit nachzuverfolgen, wie boost/program_options po::value() und die Validierung von Befehlszeilenwerten handhabt, und untersuche dann, wo eindeutige Abkürzungen von Optionen implementiert sind. Die Arbeit ist abgeschlossen, wenn eine Option die Werte "a", "b" und "c" deklarieren, "d" ablehnen, gültige Werte akzeptieren und das relevante Abkürzungsverhalten beibehalten kann.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp
Bereich
cli
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.