new CliCommandLine version

This commit is contained in:
Jon Sequeira 2017-03-10 17:11:19 -08:00
parent a3f536c248
commit 34d9cbf863
20 changed files with 72 additions and 70 deletions

View file

@ -16,7 +16,7 @@
<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>
<CliCommandLineParserVersion>0.1.0-alpha-84</CliCommandLineParserVersion>
</PropertyGroup>

View file

@ -11,7 +11,7 @@ namespace Microsoft.DotNet.Cli
Create.Option(
"-h|--help",
"Show help information",
Accept.NoArguments,
Accept.NoArguments(),
materialize: o => o.Option.Command().HelpView());
public static Option VerbosityOption() =>

View file

@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Cli
delimiters: Array.Empty<char>(),
options: Create.Command("dotnet",
".NET Command Line Tools",
Accept.NoArguments,
Accept.NoArguments(),
NewCommandParser.New(),
RestoreCommandParser.Restore(),
BuildCommandParser.Build(),

View file

@ -17,43 +17,45 @@ namespace Microsoft.DotNet.Cli
Create.Command(
"add",
".NET Add Command",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.DefaultToCurrentDirectory(),
Create.Command(
"package",
".NET Add Package reference Command",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.WithSuggestionsFrom(QueryNuGet), CommonOptions.HelpOption(),
Create.Option("-v|--version",
"Version for the package to be added.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "VERSION")
.ForwardAs(o => $"--version {o.Arguments.Single()}")),
Create.Option("-f|--framework",
"Add reference only when targetting a specific framework",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "FRAMEWORK")
.ForwardAs(o => $"--framework {o.Arguments.Single()}")),
Create.Option("-n|--no-restore ",
"Add reference without performing restore preview and compatibility check."),
Create.Option("-s|--source",
"Use specific NuGet package sources to use during the restore.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "SOURCE")
.ForwardAs(o => $"--source {o.Arguments.Single()}")),
Create.Option("--package-directory",
"Restore the packages to this Directory .",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "PACKAGE_DIRECTORY")
.ForwardAs(o => $"--package-directory {o.Arguments.Single()}"))),
Create.Command(
"reference",
"Command to add project to project reference",
Accept.OneOrMoreArguments, CommonOptions.HelpOption(),
Accept.OneOrMoreArguments(),
CommonOptions.HelpOption(),
Create.Option("-f|--framework",
"Add reference only when targetting a specific framework",
Accept.AnyOneOf(Suggest.TargetFrameworksFromProjectFile)
.With(name: "FRAMEWORK"))), CommonOptions.HelpOption());
.With(name: "FRAMEWORK"))),
CommonOptions.HelpOption());
public static IEnumerable<string> QueryNuGet(string match)
{

View file

@ -12,13 +12,13 @@ namespace Microsoft.DotNet.Cli
Create.Command(
"build",
".NET Builder",
Accept.ZeroOrOneArgument
Accept.ZeroOrOneArgument()
.Forward(),
CommonOptions.HelpOption(),
Create.Option(
"-o|--output",
"Output directory in which to place built artifacts.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "OUTPUT_DIR")
.ForwardAs(o => $"/p:OutputPath={o.Arguments.Single()}")),
Create.Option(
@ -34,14 +34,14 @@ namespace Microsoft.DotNet.Cli
Create.Option(
"-c|--configuration",
"Configuration to use for building the project. Default for most projects is \"Debug\".",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "CONFIGURATION")
.WithSuggestionsFrom("DEBUG", "RELEASE")
.ForwardAs(o => $"/p:Configuration={o.Arguments.Single()}")),
Create.Option(
"--version-suffix",
"Defines the value for the $(VersionSuffix) property in the project",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "VERSION_SUFFIX")
.ForwardAs(o => $"/p:VersionSuffix={o.Arguments.Single()}")),
Create.Option(
@ -50,7 +50,7 @@ namespace Microsoft.DotNet.Cli
Create.Option(
"--no-dependencies",
"Set this flag to ignore project-to-project references and only build the root project",
Accept.NoArguments
Accept.NoArguments()
.ForwardAs("/p:BuildProjectReferences=false")),
CommonOptions.VerbosityOption());
}

View file

@ -12,15 +12,15 @@ namespace Microsoft.DotNet.Cli
".NET Clean Command",
CommonOptions.HelpOption(),
Create.Option("-o|--output", "Directory in which the build outputs have been placed.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "OUTPUT_DIR")),
Create.Option("-f|--framework", "Clean a specific framework.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "FRAMEWORK")
.WithSuggestionsFrom(_ => Suggest.TargetFrameworksFromProjectFile())),
Create.Option("-c|--configuration",
"Clean a specific configuration.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "CONFIGURATION")
.WithSuggestionsFrom("DEBUG", "RELEASE")));
}

View file

@ -11,10 +11,10 @@ namespace Microsoft.DotNet.Cli
public static Command Complete() =>
Create.Command(
"complete", "",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "path"),
Create.Option("--position", "",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "command")
.MaterializeAs(o => int.Parse(o.Arguments.Single()))));
}

View file

@ -10,14 +10,14 @@ namespace Microsoft.DotNet.Cli
public static Command List() =>
Create.Command("list",
".NET List Command",
Accept.ZeroOrOneArgument
Accept.ZeroOrOneArgument()
.With(name: "PROJECT",
description:
"The project file to operate on. If a file is not specified, the command will search the current directory for one.")
.DefaultToCurrentDirectory(),
CommonOptions.HelpOption(),
Create.Command("reference", "Command to list project to project references",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "PROJECT",
description:
"The project file to operate on. If a file is not specified, the command will search the current directory for one."),

View file

@ -11,7 +11,7 @@ namespace Microsoft.DotNet.Cli
Create.Command("new",
"Initialize .NET projects.",
Accept
.ExactlyOneArgument
.ExactlyOneArgument()
.WithSuggestionsFrom(
"console",
"classlib",

View file

@ -15,11 +15,11 @@ namespace Microsoft.DotNet.Cli
"Show version information"),
Create.Option("-v|--verbosity",
"The verbosity of logging to use. Allowed values: Debug, Verbose, Information, Minimal, Warning, Error.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "verbosity")),
Create.Command("delete",
"Deletes a package from the server.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "root",
description: "The Package Id and version."),
CommonOptions.HelpOption(),
@ -27,13 +27,13 @@ namespace Microsoft.DotNet.Cli
"Forces the application to run using an invariant, English-based culture."),
Create.Option("-s|--source",
"Specifies the server URL",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "source")),
Create.Option("--non-interactive",
"Do not prompt for user input or confirmations."),
Create.Option("-k|--api-key",
"The API key for the server.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "apiKey"))),
Create.Command("locals",
"Clears or lists local NuGet resources such as http requests cache, packages cache or machine-wide global packages folder.",
@ -54,21 +54,21 @@ namespace Microsoft.DotNet.Cli
"Forces the application to run using an invariant, English-based culture."),
Create.Option("-s|--source",
"Specifies the server URL",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "source")),
Create.Option("-ss|--symbol-source",
"Specifies the symbol server URL. If not specified, nuget.smbsrc.net is used when pushing to nuget.org.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "source")),
Create.Option("-t|--timeout",
"Specifies the timeout for pushing to a server in seconds. Defaults to 300 seconds (5 minutes).",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "timeout")),
Create.Option("-k|--api-key", "The API key for the server.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "apiKey")),
Create.Option("-sk|--symbol-api-key", "The API key for the symbol server.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "apiKey")),
Create.Option("-d|--disable-buffering",
"Disable buffering when pushing to an HTTP(S) server to decrease memory usage."),

View file

@ -13,7 +13,7 @@ namespace Microsoft.DotNet.Cli
CommonOptions.HelpOption(),
Create.Option("-o|--output",
"Directory in which to place built packages.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "OUTPUT_DIR")),
Create.Option("--no-build",
"Skip building the project prior to packing. By default, the project will be built."),
@ -23,13 +23,13 @@ namespace Microsoft.DotNet.Cli
"Include PDBs and source files. Source files go into the src folder in the resulting nuget package"),
Create.Option("-c|--configuration",
"Configuration to use for building the project. Default for most projects is \"Debug\".",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "CONFIGURATION")
.WithSuggestionsFrom("DEBUG",
"RELEASE")),
Create.Option("--version-suffix",
"Defines the value for the $(VersionSuffix) property in the project.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "VERSION_SUFFIX")),
Create.Option("-s|--serviceable",
"Set the serviceable flag in the package. For more information, please see https://aka.ms/nupkgservicing."),

View file

@ -12,36 +12,36 @@ namespace Microsoft.DotNet.Cli
Create.Command(
"publish",
".NET Publisher",
Accept.ZeroOrMoreArguments,
Accept.ZeroOrMoreArguments(),
CommonOptions.HelpOption(),
Create.Option("-f|--framework",
"Target framework to publish for. The target framework has to be specified in the project file.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.WithSuggestionsFrom(_ => Suggest.TargetFrameworksFromProjectFile())
.With(name: "FRAMEWORK")
.ForwardAs(o => $"/p:TargetFramework={o.Arguments.Single()}")),
Create.Option("-r|--runtime",
"Publish the project for a given runtime. This is used when creating self-contained deployment. Default is to publish a framework-dependent app.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.WithSuggestionsFrom(_ => Suggest.RunTimesFromProjectFile())
.With(name: "RUNTIME_IDENTIFIER")
.ForwardAs(o => $"/p:RuntimeIdentifier={o.Arguments.Single()}")),
Create.Option("-o|--output",
"Output directory in which to place the published artifacts.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "OUTPUT_DIR")
.ForwardAs(o => $"/p:PublishDir={o.Arguments.Single()}")),
Create.Option("-c|--configuration", "Configuration to use for building the project. Default for most projects is \"Debug\".",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "CONFIGURATION")
.WithSuggestionsFrom("DEBUG", "RELEASE")
.ForwardAs(o => $"/p:Configuration={o.Arguments.Single()}")),
Create.Option("--version-suffix", "Defines the value for the $(VersionSuffix) property in the project.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "VERSION_SUFFIX")
.ForwardAs(o => $"/p:VersionSuffix={o.Arguments.Single()}")),
Create.Option("--filter", "The XML file that contains the list of packages to be excluded from publish step.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "PROFILE_XML")
.ForwardAs(o => $"/p:FilterProjectFiles={o.Arguments.Single()}")),
CommonOptions.VerbosityOption());

View file

@ -10,7 +10,7 @@ namespace Microsoft.DotNet.Cli
public static Command Remove() =>
Create.Command("remove",
".NET Remove Command",
Accept.ZeroOrOneArgument
Accept.ZeroOrOneArgument()
.With(name: "PROJECT")
.DefaultToCurrentDirectory(),
CommonOptions.HelpOption(),
@ -23,7 +23,7 @@ namespace Microsoft.DotNet.Cli
CommonOptions.HelpOption(),
Create.Option("-f|--framework",
"Remove reference only when targetting a specific framework",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "FRAMEWORK"))));
}
}

View file

@ -12,52 +12,52 @@ namespace Microsoft.DotNet.Cli
Create.Command(
"restore",
".NET dependency restorer",
Accept.ZeroOrMoreArguments,
Accept.ZeroOrMoreArguments(),
CommonOptions.HelpOption(),
Create.Option(
"-s|--source",
"Specifies a NuGet package source to use during the restore.",
Accept.OneOrMoreArguments
Accept.OneOrMoreArguments()
.With(name: "SOURCE")
.ForwardAs(o => $"/p:RestoreSources={string.Join("%3B", o.Arguments)}")),
Create.Option(
"-r|--runtime",
"Target runtime to restore packages for.",
Accept.OneOrMoreArguments
Accept.OneOrMoreArguments()
.WithSuggestionsFrom(_ => Suggest.RunTimesFromProjectFile())
.With(name: "RUNTIME_IDENTIFIER")
.ForwardAs(o => $"/p:RuntimeIdentifiers={string.Join("%3B", o.Arguments)}")),
Create.Option(
"--packages",
"Directory to install packages in.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "PACKAGES_DIRECTORY")
.ForwardAs(o => $"/p:RestorePackagesPath={o.Arguments.Single()}")),
Create.Option(
"--disable-parallel",
"Disables restoring multiple projects in parallel.",
Accept.NoArguments
Accept.NoArguments()
.ForwardAs("/p:RestoreDisableParallel=true")),
Create.Option(
"--configfile",
"The NuGet configuration file to use.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "FILE")
.ForwardAs(o => $"/p:RestoreConfigFile={o.Arguments.Single()}")),
Create.Option(
"--no-cache",
"Do not cache packages and http requests.",
Accept.NoArguments
Accept.NoArguments()
.ForwardAs("/p:RestoreNoCache=true")),
Create.Option(
"--ignore-failed-sources",
"Treat package source failures as warnings.",
Accept.NoArguments
Accept.NoArguments()
.ForwardAs("/p:RestoreIgnoreFailedSources=true")),
Create.Option(
"--no-dependencies",
"Set this flag to ignore project to project references and only restore the root project",
Accept.NoArguments
Accept.NoArguments()
.ForwardAs("/p:RestoreRecursive=false")),
CommonOptions.VerbosityOption());
}

View file

@ -13,13 +13,13 @@ namespace Microsoft.DotNet.Cli
CommonOptions.HelpOption(),
Create.Option("-c|--configuration",
@"Configuration to use for building the project. Default for most projects is ""Debug"".",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.WithSuggestionsFrom("DEBUG", "RELEASE")),
Create.Option("-f|--framework",
"Build and run the app using the specified framework. The framework has to be specified in the project file.",
Accept.AnyOneOf(Suggest.TargetFrameworksFromProjectFile)),
Create.Option("-p|--project",
"The path to the project file to run (defaults to the current directory if there is only one project).",
Accept.ZeroOrOneArgument));
Accept.ZeroOrOneArgument()));
}
}

View file

@ -13,12 +13,12 @@ namespace Microsoft.DotNet.Cli
CommonOptions.HelpOption(),
Create.Command("add",
".NET Add project(s) to a solution file Command",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "SLN_FILE"),
CommonOptions.HelpOption()),
Create.Command("list",
"List all projects in the solution.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "SLN_FILE"),
CommonOptions.HelpOption()),
Create.Command("remove",

View file

@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Cli
"Show help information"),
Create.Option("-s|--settings",
"Settings to use when running tests.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "SETTINGS_FILE")),
Create.Option("-t|--list-tests",
"Lists discovered tests"),
@ -23,16 +23,16 @@ namespace Microsoft.DotNet.Cli
Run a test with the specified full name: --filter ""FullyQualifiedName=Namespace.ClassName.MethodName""
Run tests that contain the specified name: --filter ""FullyQualifiedName~Namespace.Class""
More info on filtering support: https://aka.ms/vstest-filtering",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "EXPRESSION")),
Create.Option("-a|--test-adapter-path",
"Use custom adapters from the given path in the test run.\r\n Example: --test-adapter-path <PATH_TO_ADAPTER>"),
Create.Option("-l|--logger",
"Specify a logger for test results.\r\n Example: --logger \"trx[;LogFileName=<Defaults to unique file name>]\"",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "LoggerUri/FriendlyName")),
Create.Option("-c|--configuration", "Configuration to use for building the project. Default for most projects is \"Debug\".",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "CONFIGURATION")
.WithSuggestionsFrom("DEBUG", "RELEASE")),
Create.Option("-f|--framework",
@ -41,11 +41,11 @@ namespace Microsoft.DotNet.Cli
.With(name: "FRAMEWORK")),
Create.Option("-o|--output",
"Directory in which to find the binaries to be run",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "OUTPUT_DIR")),
Create.Option("-d|--diag",
"Enable verbose logs for test platform.\r\n Logs are written to the provided file.",
Accept.ExactlyOneArgument
Accept.ExactlyOneArgument()
.With(name: "PATH_TO_FILE")),
Create.Option("--no-build",
"Do not build project before testing."),

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-80" />
<PackageReference Include="Microsoft.DotNet.Cli.CommandLine" Version="0.1.0-alpha-84" />
<PackageReference Include="Microsoft.TemplateEngine.Abstractions" Version="$(TemplateEngineVersion)" />
<PackageReference Include="Microsoft.TemplateEngine.Cli" Version="$(TemplateEngineVersion)" />
<PackageReference Include="Microsoft.TemplateEngine.Orchestrator.RunnableProjects" Version="$(TemplateEngineVersion)" />

View file

@ -18,10 +18,10 @@ namespace Microsoft.DotNet.Tests.ParserTests
{
var command = Command("the-command", "",
Option("-o|--one", "",
ZeroOrOneArgument
ZeroOrOneArgument()
.ForwardAs(o => $"/i:{o.Arguments.Single()}")),
Option("-t|--two", "",
NoArguments
NoArguments()
.ForwardAs("/s:true")));
var result = command.Parse("the-command -t -o 123");
@ -37,7 +37,7 @@ namespace Microsoft.DotNet.Tests.ParserTests
{
var command = Command("the-command", "",
Option("-x", "",
ZeroOrMoreArguments
ZeroOrMoreArguments()
.ForwardAs(o => $"/x:{string.Join("&", o.Arguments)}")));
var result = command.Parse("the-command -x one -x two");
@ -53,7 +53,7 @@ namespace Microsoft.DotNet.Tests.ParserTests
{
var command = Command("the-command", "",
Option("-x", "",
ZeroOrMoreArguments
ZeroOrMoreArguments()
.Forward()));
var result = command.Parse("the-command -x one");

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-80" />
<PackageReference Include="Microsoft.DotNet.Cli.CommandLine" Version="0.1.0-alpha-84" />
</ItemGroup>
</Project>