Skip to content

Automatic binding of consecutive parameters to collection #368

Description

@Starkie

Some CLI programs infer that a list of consecutive parameters belong to the same option. For example, the program cp in unix has the following profile, were one or more source files can be specified to be copied to directory:

cp [OPTION]... SOURCE... DIRECTORY

The usage would be as following:

cp file1 file2 directory

I tried to implement a similar behaviour in a command line program, that receives a collection of paths:

static void Main(string[] paths)
{
  // Do something
}

I expected to invoke the program like this:
dotnet run -- --paths file1 file2 file3

But instead, the argument name had to be specified each time:
dotnet run -- --paths file1 --paths file2 --paths file3

Does a way to implement options with a similar behaviour exist?

Might be related to #310.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions