Skip to content

How to provide a default for .many() parsers #82

Answered by xitep
xitep asked this question in Q&A
Discussion options

You must be logged in to vote

one way to achieve a default value would be this:

let roots = bpaf::positional::<String>("ROOTS").many().map(|items| {
        if items.is_empty() {
            vec![String::from(".")]
        } else {
            items
        }
    });

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by pacak
Comment options

You must be logged in to vote
0 replies
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