Skip to content
Discussion options

You must be logged in to vote

There isn't an explicit example of this.. but it is supported in two alternatives. If you pass in a container, i.e. std::vector, as the binding value the multiple options will automatically collect into the vector:

std::vector<std::string> all_values;
cli |= lyra::opt(all_values, "value").name("-h");

The other is you can pass a lambda for the bound value that can collect as you wish. For example to collect only unique numbers:

std::unordered_set<int> unique_values;
cli |= lyra::opt([&](int v) { unique_values.insert(v); }, "value").name("-i").cardinality(0,0);

For that the latter you need to specify the cardinality as it default to one argument. The former defaults to multiple as it assu…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Xxproner
Comment options

Answer selected by Xxproner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants