WIP
This commit is contained in:
parent
30480fa189
commit
fd6f7e48b5
5 changed files with 24 additions and 13 deletions
|
@ -2,10 +2,20 @@
|
|||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
|
||||
namespace Microsoft.DotNet.Cli
|
||||
{
|
||||
public static class ParserExtensions
|
||||
{
|
||||
public static ParseResult ParseFrom(
|
||||
this CommandLine.Parser parser,
|
||||
string context,
|
||||
string[] args) =>
|
||||
parser.Parse(context.Split(' ').Concat(args).ToArray());
|
||||
}
|
||||
|
||||
public static class ParseResultExtensions
|
||||
{
|
||||
public static void ShowHelp(this ParseResult parseResult) =>
|
||||
|
|
|
@ -19,10 +19,10 @@ namespace Microsoft.DotNet.Cli
|
|||
DebugHelper.HandleDebugSwitch(ref args);
|
||||
|
||||
// get the parser for the current subcommand
|
||||
var parser = Parser.Instance["dotnet"]["complete"];
|
||||
var parser = Parser.Instance;
|
||||
|
||||
// parse the arguments
|
||||
var result = parser.Parse(args);
|
||||
var result = parser.ParseFrom("dotnet complete", args);
|
||||
|
||||
var complete = result["complete"];
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@ namespace Microsoft.DotNet.Cli
|
|||
Create.Command(
|
||||
"complete", "",
|
||||
Accept.ExactlyOneArgument
|
||||
.With(name: "path")
|
||||
.MaterializeAs(o => int.Parse(o.Arguments.Single())),
|
||||
.With(name: "path"),
|
||||
Create.Option("--position", "",
|
||||
Accept.ExactlyOneArgument
|
||||
.With(name: "command")));
|
||||
Accept.ExactlyOneArgument
|
||||
.With(name: "command")
|
||||
.MaterializeAs(o => int.Parse(o.Arguments.Single()))));
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.Tools.MSBuild;
|
||||
|
@ -22,9 +23,9 @@ namespace Microsoft.DotNet.Tools.Restore
|
|||
{
|
||||
DebugHelper.HandleDebugSwitch(ref args);
|
||||
|
||||
var parser = Parser.Instance["dotnet"];
|
||||
var parser = Parser.Instance;
|
||||
|
||||
var result = parser.Parse(args);
|
||||
var result = parser.ParseFrom("dotnet restore", args);
|
||||
|
||||
Reporter.Verbose.WriteLine(result.Diagram());
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ namespace Microsoft.DotNet.Tests.ParserTests
|
|||
[Fact]
|
||||
public void RestoreCapturesArgumentsToForwardToMSBuildWhenTargetIsSpecified()
|
||||
{
|
||||
var parser = Parser.Instance["dotnet"];
|
||||
var parser = Parser.Instance["dotnet"]["restore"];
|
||||
|
||||
var result = parser.Parse(@"restore .\some.csproj --packages c:\.nuget\packages /p:SkipInvalidConfigurations=true");
|
||||
var result = parser.Parse(@".\some.csproj --packages c:\.nuget\packages /p:SkipInvalidConfigurations=true");
|
||||
|
||||
output.WriteLine(result.Diagram());
|
||||
|
||||
|
@ -37,9 +37,9 @@ namespace Microsoft.DotNet.Tests.ParserTests
|
|||
[Fact]
|
||||
public void RestoreCapturesArgumentsToForwardToMSBuildWhenTargetIsNotSpecified()
|
||||
{
|
||||
var parser = Parser.Instance["dotnet"];
|
||||
var parser = Parser.Instance["dotnet"]["restore"];
|
||||
|
||||
var result = parser.Parse(@"restore --packages c:\.nuget\packages /p:SkipInvalidConfigurations=true");
|
||||
var result = parser.Parse(@"--packages c:\.nuget\packages /p:SkipInvalidConfigurations=true");
|
||||
|
||||
output.WriteLine(result.Diagram());
|
||||
|
||||
|
|
Loading…
Reference in a new issue