Skip to content

How to use ArgAction::Append with derive instead of builder? #4331

Answered by epage
sloganking asked this question in Q&A
Discussion options

You must be logged in to vote

Something like --flag val1 val2 instead of --flag val1 --flag val2

That is the opposite of ArgAction::Append. Assuming you are using clap v4, you want num_args.

Keep in mind what clap automatically does based on the field's type](https://docs.rs/clap/latest/clap/_derive/index.html#arg-types) as you will want to consider how much you want to undo.

It looks like ArgAction::Append can do this. However the documentation for it is always under the builder section of the docs.

The derive reference explains raw attributes and delegates documentation for them to the builder API.

See also #4090

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@sloganking
Comment options

@epage
Comment options

epage Oct 4, 2022
Maintainer

@sloganking
Comment options

@epage
Comment options

epage Oct 5, 2022
Maintainer

Answer selected by sloganking
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