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

howto: simulate K V checked args list #1070

Open
leaveye opened this issue Sep 15, 2024 · 1 comment
Open

howto: simulate K V checked args list #1070

leaveye opened this issue Sep 15, 2024 · 1 comment

Comments

@leaveye
Copy link

leaveye commented Sep 15, 2024

i want to write a helper tool to edit configure on my target box.

suppose we have config-entries constants:

# `key1` accept only `value1` and `value2`
key1: value1 value2
key2: foo bar baz

is there a way to let my tool command line like:

set-helper key1 value1 key2 refused

and with param validation works with both key and values?


i have imagined a way that takes vector<string> arg and do check in a sort-of-callback. but seems not fit the CLI11 design principle. any suggestion?

@phlptp
Copy link
Collaborator

phlptp commented Sep 19, 2024

The simplest way is probably just a custom callback that does some additional checks. You could probably do a stateful validator that does the checks inline, but I think in this case a callback on the app that does the checks would be the simplest choice, then you have access to the entire vector.

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