Skip to content

Distinguish between multiple sets of values for a multiple, min_values arg #1026

@soumya92

Description

@soumya92

Rust Version

rustc 1.19.0 (0ade33941 2017-07-17)

Affected Version of clap

clap 2.25.0

Expected Behavior Summary

It would be nice to be able to distinguish between -a A B C D E and -a A B -a C D E, where -a is an arg with min_values(2) and multiple(true).

From clap::Arg::min_values

NOTE: This does not implicitly set Arg::multiple(true). This is because -o val -o val is multiple occurrences but a single value and -o val1 val2 is a single occurence with multiple values.

This seems to imply that such a distinction is already possible. But the test option_min_exact demonstrates exactly the opposite behaviour.

A toy example of where this might be useful is a backup program. It might allow users to backup files to multiple "targets", for example, with common settings specified once. An invocation might look like:

backup -s server -u user -target target1 file1 file2 file3 -target target2 file4 file5 file6 file7 -target target3 file8

Currently there seems to be no way to determine that target1, target2, and target3 appeared immediately after -target. All we know is that there are three targets (occurrences_of("target")), but values_of("target") will just iterate over target1 file1 file2 file3 target2 file4 file5 file6 file7 target3 file8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions