Skip to content

Multiple value of Option #383

@WojciechNagorski

Description

@WojciechNagorski

I'm trying to switch BenchmarkDotNet (dotnet/BenchmarkDotNet#1016) to System.CommandLine.

But I have one problem. Currently BenchmarkDotNet uses multiple value of argument e.g.:
dotnet run -c Release -- --runtimes net472 netcoreapp2.1
or
--filter *ClassA* *ClassB*

Currently System.CommandLine doesn't support this. When I configure option:

   Option Filter() => new Option(new[] { "-r", "--runtimes" },
        "Full target framework moniker for .NET Core and .NET. For Mono just 'Mono', for CoreRT just 'CoreRT'. First one will be marked as baseline!",
        new Argument<string[]>());

I have to repeat an alias for each parameter value, like this:
--runtimes net472 --runtimes netcoreapp2.1

The worst scenario, instead:
--filter *ClassA* *ClassB* --runtimes net472 netcoreapp2.1 --exporters GitHub StackOverflow RPlot CSV JSON HTML XML --attribute Attribute1 Attribute2
we should type this:
--filter *ClassA* --filter *ClassB* --runtimes net472 --runtimes netcoreapp2.1 --exporters GitHub --exporters StackOverflow --exporters RPlot --exporters CSV --exporters JSON --exporters HTML --exporters XML --attribute Attribute1 --attribute Attribute2
This example doesn't contain other attributes that can have one value.

There is unit test that shows it doesn't work

[InlineData("--one 1 --many 1 --many 2")]
[InlineData("--one 1 --many 1 --many 2 arg1 arg2")]
[InlineData("--many 1 --one 1 --many 2")]
[InlineData("--many 2 --many 1 --one 1")]
[InlineData("--many:2 --many=1 --one 1")]
[InlineData("[parse] --one 1 --many 1 --many 2")]
[InlineData("--one \"stuff in quotes\" this-is-arg1 \"this is arg2\"")]
[InlineData("not a valid command line --one 1")]
public void Original_order_of_tokens_is_preserved_in_ParseResult_Tokens(string commandLine)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions