From 7a90675be78b134a3d79e406f8985d3ddf472296 Mon Sep 17 00:00:00 2001 From: jonsequitur Date: Thu, 30 Mar 2017 07:43:04 -0700 Subject: [PATCH] enforce repeating options to for multiple arguments --- .../dotnet-publish/PublishCommandParser.cs | 14 +++++------ src/dotnet/dotnet.csproj | 2 +- .../ParserTests/RestoreParserTests.cs | 23 +++++++++++++++++++ test/dotnet.Tests/dotnet.Tests.csproj | 2 +- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/dotnet/commands/dotnet-publish/PublishCommandParser.cs b/src/dotnet/commands/dotnet-publish/PublishCommandParser.cs index 0372ae89f..231895316 100644 --- a/src/dotnet/commands/dotnet-publish/PublishCommandParser.cs +++ b/src/dotnet/commands/dotnet-publish/PublishCommandParser.cs @@ -20,17 +20,17 @@ namespace Microsoft.DotNet.Cli Create.Option( "-o|--output", LocalizableStrings.OutputOptionDescription, - Accept.ExactlyOneArgument() - .With(name: LocalizableStrings.OutputOption) - .ForwardAsSingle(o => $"/p:PublishDir={o.Arguments.Single()}")), + Accept.ExactlyOneArgument() + .With(name: LocalizableStrings.OutputOption) + .ForwardAsSingle(o => $"/p:PublishDir={o.Arguments.Single()}")), CommonOptions.ConfigurationOption(), CommonOptions.VersionSuffixOption(), Create.Option( - "--filter", + "--filter", LocalizableStrings.FilterProjOptionDescription, - Accept.OneOrMoreArguments() - .With(name: LocalizableStrings.FilterProjOption) - .ForwardAsSingle(o => $"/p:FilterProjectFiles={string.Join("%3B", o.Arguments)}")), + Accept.OneOrMoreArguments() + .With(name: LocalizableStrings.FilterProjOption) + .ForwardAsSingle(o => $"/p:FilterProjectFiles={string.Join("%3B", o.Arguments)}")), CommonOptions.VerbosityOption()); } } \ No newline at end of file diff --git a/src/dotnet/dotnet.csproj b/src/dotnet/dotnet.csproj index 1af752ea6..9a5233bdc 100644 --- a/src/dotnet/dotnet.csproj +++ b/src/dotnet/dotnet.csproj @@ -40,7 +40,7 @@ - + diff --git a/test/dotnet.Tests/ParserTests/RestoreParserTests.cs b/test/dotnet.Tests/ParserTests/RestoreParserTests.cs index 48a566b92..726c6be8e 100644 --- a/test/dotnet.Tests/ParserTests/RestoreParserTests.cs +++ b/test/dotnet.Tests/ParserTests/RestoreParserTests.cs @@ -44,5 +44,28 @@ namespace Microsoft.DotNet.Tests.ParserTests .Should() .BeEquivalentTo(@"/p:SkipInvalidConfigurations=true"); } + + [Fact] + public void RestoreDistinguishesRepeatSourceArgsFromCommandArgs() + { + var restore = + Parser.Instance + .Parse( + @"dotnet restore --no-cache --packages ""D:\OSS\corefx\packages"" --source https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json --source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json --source https://api.nuget.org/v3/index.json D:\OSS\corefx\external\runtime\runtime.depproj") + .AppliedCommand(); + + restore + .Arguments + .Should() + .BeEquivalentTo(@"D:\OSS\corefx\external\runtime\runtime.depproj"); + + restore["--source"] + .Arguments + .Should() + .BeEquivalentTo( + "https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json", + "https://dotnet.myget.org/F/dotnet-core/api/v3/index.json", + "https://api.nuget.org/v3/index.json"); + } } } \ No newline at end of file diff --git a/test/dotnet.Tests/dotnet.Tests.csproj b/test/dotnet.Tests/dotnet.Tests.csproj index 025e06c9c..5e2e6d54e 100644 --- a/test/dotnet.Tests/dotnet.Tests.csproj +++ b/test/dotnet.Tests/dotnet.Tests.csproj @@ -42,6 +42,6 @@ - +