don't split on : or = in restore command parse

This commit is contained in:
Jon Sequeira 2017-03-07 11:28:35 -08:00
parent c176b5953f
commit 1ed5b420a9
10 changed files with 80 additions and 55 deletions

View file

@ -16,6 +16,8 @@
<TemplateEngineTemplate2_0Version>1.0.0-beta1-20170209-117</TemplateEngineTemplate2_0Version>
<PlatformAbstractionsVersion>1.0.3</PlatformAbstractionsVersion>
<DependencyModelVersion>1.0.3</DependencyModelVersion>
<CliCommandLineParserVersion>0.1.0-alpha-74</CliCommandLineParserVersion>
</PropertyGroup>
<!-- infrastructure and test only dependencies -->

View file

@ -1,7 +1,7 @@
# PowerShell parameter completion shim for the dotnet CLI
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
dotnet.exe complete --position $cursorPosition "$wordToComplete" | ForEach-Object {
C:\dev\github\cli\artifacts\win10-x64\stage2\dotnet.exe complete --position $cursorPosition "$wordToComplete" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}

View file

@ -1,21 +0,0 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// 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
{
internal static class CompleteCommandParser
{
public static Command Complete() =>
Create.Command("complete", "",
Accept.ExactlyOneArgument
.With(name: "path"),
Create.Option("--position", "",
Accept.ExactlyOneArgument
.With(name: "command"),
o => Int32.Parse(o.Arguments.Single())));
}
}

View file

@ -80,7 +80,7 @@ namespace Microsoft.DotNet.Cli
UseShellExecute = false
};
Reporter.Verbose.WriteLine($"[Forwarding] {processInfo.FileName} {processInfo.Arguments}");
Reporter.Output.WriteLine($"[Forwarding] {processInfo.FileName} {processInfo.Arguments}");
if (_environmentVariables != null)
{

View file

@ -8,32 +8,49 @@ namespace Microsoft.DotNet.Cli
internal static class BuildCommandParser
{
public static Command Build() =>
Create.Command("build",
Create.Command(
"build",
".NET Builder",
Accept.ZeroOrOneArgument
.ForwardAs("{0}"),
CommonOptions.HelpOption(),
Create.Option("-o|--output",
Create.Option(
"-o|--output",
"Output directory in which to place built artifacts.",
Accept.ExactlyOneArgument
.With(name: "OUTPUT_DIR")),
Create.Option("-f|--framework",
.With(name: "OUTPUT_DIR")
.ForwardAs("/p:OutputPath={0}")),
Create.Option(
"-f|--framework",
"Target framework to build for. The target framework has to be specified in the project file.",
Accept.AnyOneOf(Suggest.TargetFrameworksFromProjectFile)),
Create.Option("-r|--runtime",
Accept.AnyOneOf(Suggest.TargetFrameworksFromProjectFile)
.ForwardAs("/p:TargetFramework={0}")),
Create.Option(
"-r|--runtime",
"Target runtime to build for. The default is to build a portable application.",
Accept.AnyOneOf(Suggest.RunTimesFromProjectFile)),
Create.Option("-c|--configuration",
Accept.AnyOneOf(Suggest.RunTimesFromProjectFile)
.ForwardAs("/p:RuntimeIdentifier={0}")),
Create.Option(
"-c|--configuration",
"Configuration to use for building the project. Default for most projects is \"Debug\".",
Accept.ExactlyOneArgument
.With(name: "CONFIGURATION")
.WithSuggestionsFrom("DEBUG", "RELEASE")),
Create.Option("--version-suffix",
.WithSuggestionsFrom("DEBUG", "RELEASE")
.ForwardAs("/p:Configuration={0}")),
Create.Option(
"--version-suffix",
"Defines the value for the $(VersionSuffix) property in the project",
Accept.ExactlyOneArgument
.With(name: "VERSION_SUFFIX")),
Create.Option("--no-incremental",
.With(name: "VERSION_SUFFIX")
.ForwardAs("/p:VersionSuffix={0}")),
Create.Option(
"--no-incremental",
"Disables incremental build."),
Create.Option("--no-dependencies",
"Set this flag to ignore project-to-project references and only build the root project"),
Create.Option(
"--no-dependencies",
"Set this flag to ignore project-to-project references and only build the root project",
Accept.NoArguments
.ForwardAs("/p:BuildProjectReferences=false")),
CommonOptions.VerbosityOption());
}
}

View file

@ -0,0 +1,21 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Linq;
using Microsoft.DotNet.Cli.CommandLine;
namespace Microsoft.DotNet.Cli
{
internal static class CompleteCommandParser
{
public static Command Complete() =>
Create.Command(
"complete", "",
Accept.ExactlyOneArgument
.With(name: "path")
.MaterializeAs(o => int.Parse(o.Arguments.Single())),
Create.Option("--position", "",
Accept.ExactlyOneArgument
.With(name: "command")));
}
}

View file

@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Utils;
@ -21,10 +22,14 @@ namespace Microsoft.DotNet.Tools.Restore
{
DebugHelper.HandleDebugSwitch(ref args);
var parser = Parser.DotnetCommand["restore"];
var parser = new Cli.CommandLine.Parser(
delimiters: Array.Empty<char>(),
options: Parser.DotnetCommand["restore"]);
var result = parser.Parse(args);
Reporter.Verbose.WriteLine(result.Diagram());
var restore = result["restore"];
var msbuildArgs = new List<string>

View file

@ -8,9 +8,10 @@ namespace Microsoft.DotNet.Cli
internal static class RestoreCommandParser
{
public static Command Restore() =>
Create.Command("restore",
Create.Command(
"restore",
".NET dependency restorer",
Accept.OneOrMoreArguments,
Accept.ExactlyOneArgument,
CommonOptions.HelpOption(),
Create.Option(
"-s|--source",

View file

@ -40,7 +40,7 @@
<PackageReference Include="Microsoft.Win32.Registry" Version="4.3.0" />
<PackageReference Include="Microsoft.Build" Version="$(CLI_MSBuild_Version)" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="$(PlatformAbstractionsVersion)" />
<PackageReference Include="Microsoft.DotNet.Cli.CommandLine" Version="0.1.0-alpha-74" />
<PackageReference Include="Microsoft.DotNet.Cli.CommandLine" Version="0.1.0-alpha-76" />
<PackageReference Include="Microsoft.TemplateEngine.Abstractions" Version="$(TemplateEngineVersion)" />
<PackageReference Include="Microsoft.TemplateEngine.Cli" Version="$(TemplateEngineVersion)" />
<PackageReference Include="Microsoft.TemplateEngine.Orchestrator.RunnableProjects" Version="$(TemplateEngineVersion)" />

View file

@ -42,6 +42,6 @@
<PackageReference Include="xunit" Version="2.2.0-beta4-build3444" />
<PackageReference Include="xunit.netcore.extensions" Version="1.0.0-prerelease-00206" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="$(PlatformAbstractionsVersion)" />
<PackageReference Include="Microsoft.DotNet.Cli.CommandLine" Version="[0.1.0-alpha-74,)" />
<PackageReference Include="Microsoft.DotNet.Cli.CommandLine" Version="0.1.0-alpha-76" />
</ItemGroup>
</Project>