dotnet run doesn't accept '--' arg separator anymore

When moving from System.CommandLine to the DNX arg parser, we regressed in parsing arguments that should be passed to the underlying process.

Fix #2643
This commit is contained in:
Eric Erhardt 2016-04-22 16:01:17 -05:00
parent 705a48940f
commit dd327b52a5
2 changed files with 18 additions and 7 deletions

View file

@ -44,6 +44,7 @@ namespace Microsoft.DotNet.Cli.CommandLine
public Func<string> ShortVersionGetter { get; set; }
public List<CommandLineApplication> Commands { get; private set; }
public bool HandleResponseFiles { get; set; }
public bool AllowArgumentSeparator { get; set; }
public CommandLineApplication Command(string name, Action<CommandLineApplication> configuration,
bool throwOnUnexpectedArg = true)
@ -129,10 +130,18 @@ namespace Microsoft.DotNet.Cli.CommandLine
if (longOption != null)
{
processed = true;
option = command.Options.SingleOrDefault(opt => string.Equals(opt.LongName, longOption[0], StringComparison.Ordinal));
string longOptionName = longOption[0];
option = command.Options.SingleOrDefault(opt => string.Equals(opt.LongName, longOptionName, StringComparison.Ordinal));
if (option == null)
{
if (string.IsNullOrEmpty(longOptionName) && !command._throwOnUnexpectedArg && AllowArgumentSeparator)
{
// a stand-alone "--" is the argument separator, so skip it and
// handle the rest of the args as unexpected args
index++;
}
HandleUnexpectedArg(command, args, index, argTypeName: "option");
break;
}
@ -405,6 +414,11 @@ namespace Microsoft.DotNet.Cli.CommandLine
}
}
if (target.AllowArgumentSeparator)
{
headerBuilder.Append(" [[--] <arg>...]]");
}
headerBuilder.AppendLine();
var nameAndVersion = new StringBuilder();