diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 6236b9b98ec..5c08cc4a108 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -13,9 +13,9 @@ 1df7df81ac783e63aa7fbccb0232ad20fb128b15 - + https://github.com/dotnet/command-line-api - 3bbb940ceeb3254790899d751a8d418348563d40 + 48bd86bdcd926a194e1581a60d820d12a64ef3c6 diff --git a/eng/Versions.props b/eng/Versions.props index e04746216c9..cf0bd6798f1 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -15,7 +15,7 @@ 9.0.0 - 2.0.0-beta4.25071.2 + 2.0.0-beta5.25208.1 9.0.3 9.0.3 9.0.3 diff --git a/test/Microsoft.TemplateEngine.Authoring.CLI.UnitTests/ValidateCommandTests.cs b/test/Microsoft.TemplateEngine.Authoring.CLI.UnitTests/ValidateCommandTests.cs index fbb400db5dc..7d17777be84 100644 --- a/test/Microsoft.TemplateEngine.Authoring.CLI.UnitTests/ValidateCommandTests.cs +++ b/test/Microsoft.TemplateEngine.Authoring.CLI.UnitTests/ValidateCommandTests.cs @@ -12,7 +12,7 @@ public class ValidateCommandTests : TestBase [Fact] public async Task ValidateCommand_BasicTest_InvalidTemplate() { - CliRootCommand root = new() + RootCommand root = new() { new ValidateCommand() }; @@ -26,7 +26,7 @@ public async Task ValidateCommand_BasicTest_InvalidTemplate() [Fact] public async Task ValidateCommand_BasicTest_ValidTemplate() { - CliRootCommand root = new() + RootCommand root = new() { new ValidateCommand() }; diff --git a/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/ExecutableCommand.cs b/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/ExecutableCommand.cs index a6aa653b08f..529aca1b110 100644 --- a/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/ExecutableCommand.cs +++ b/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/ExecutableCommand.cs @@ -9,9 +9,9 @@ namespace Microsoft.TemplateEngine.Authoring.CLI.Commands { /// - /// Represents a together with its action. + /// Represents a together with its action. /// - internal abstract class ExecutableCommand : CliCommand where TModel : class + internal abstract class ExecutableCommand : Command where TModel : class { internal ExecutableCommand(string name, string? description = null) : base(name, description) @@ -29,7 +29,7 @@ internal ExecutableCommand(string name, string? description = null) /// protected abstract Task ExecuteAsync(TModel args, ILoggerFactory loggerFactory, CancellationToken cancellationToken); - private sealed class CommandAction : AsynchronousCliAction + private sealed class CommandAction : AsynchronousCommandLineAction { private readonly ExecutableCommand _command; diff --git a/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/Verify/VerifyCommand.cs b/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/Verify/VerifyCommand.cs index 3753c316a9e..f6a5862f924 100644 --- a/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/Verify/VerifyCommand.cs +++ b/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/Verify/VerifyCommand.cs @@ -12,72 +12,72 @@ internal class VerifyCommand : ExecutableCommand { private const string CommandName = "verify"; - private readonly CliArgument _templateNameArgument = new("template-short-name") + private readonly Argument _templateNameArgument = new("template-short-name") { Description = LocalizableStrings.command_verify_help_templateName_description, // 0 for case where only path is specified Arity = new ArgumentArity(1, 1) }; - private readonly CliOption _remainingArguments = new("--template-args") + private readonly Option _remainingArguments = new("--template-args") { Description = "Template specific arguments - all joined into single enquoted string. Any needed quotations of actual arguments has to be escaped.", Arity = new ArgumentArity(0, 1) }; - private readonly CliOption _templatePathOption = new("--template-path", "-p") + private readonly Option _templatePathOption = new("--template-path", "-p") { Description = LocalizableStrings.command_verify_help_templatePath_description, }; - private readonly CliOption _templateOutputPathOption = new("--output", "-o") + private readonly Option _templateOutputPathOption = new("--output", "-o") { Description = LocalizableStrings.command_verify_help_outputPath_description, }; - private readonly CliOption _snapshotsDirectoryOption = new("--snapshots-directory", "-d") + private readonly Option _snapshotsDirectoryOption = new("--snapshots-directory", "-d") { Description = LocalizableStrings.command_verify_help_snapshotsDirPath_description, }; - private readonly CliOption _scenarioNameOption = new("--scenario-name") + private readonly Option _scenarioNameOption = new("--scenario-name") { Description = LocalizableStrings.command_verify_help_scenarioName_description, }; - private readonly CliOption _disableDiffToolOption = new("--disable-diff-tool") + private readonly Option _disableDiffToolOption = new("--disable-diff-tool") { Description = LocalizableStrings.command_verify_help_disableDiffTool_description, }; - private readonly CliOption _disableDefaultExcludePatternsOption = new("--disable-default-exclude-patterns") + private readonly Option _disableDefaultExcludePatternsOption = new("--disable-default-exclude-patterns") { Description = LocalizableStrings.command_verify_help_disableDefaultExcludes_description, }; - private readonly CliOption> _excludePatternOption = new("--exclude-pattern") + private readonly Option> _excludePatternOption = new("--exclude-pattern") { Description = LocalizableStrings.command_verify_help_customExcludes_description, Arity = new ArgumentArity(0, 999) }; - private readonly CliOption> _includePatternOption = new("--include-pattern") + private readonly Option> _includePatternOption = new("--include-pattern") { Description = LocalizableStrings.command_verify_help_customIncludes_description, Arity = new ArgumentArity(0, 999) }; - private readonly CliOption _verifyCommandOutputOption = new("--verify-std") + private readonly Option _verifyCommandOutputOption = new("--verify-std") { Description = LocalizableStrings.command_verify_help_verifyOutputs_description, }; - private readonly CliOption _isCommandExpectedToFailOption = new("--fail-expected") + private readonly Option _isCommandExpectedToFailOption = new("--fail-expected") { Description = LocalizableStrings.command_verify_help_expectFailure_description, }; - private readonly CliOption> _uniqueForOption = new("--unique-for") + private readonly Option> _uniqueForOption = new("--unique-for") { Description = LocalizableStrings.command_verify_help_uniqueFor_description, Arity = new ArgumentArity(0, 999), @@ -171,9 +171,9 @@ await engine.Execute( } /// - /// Case insensitive version for . + /// Case insensitive version for . /// - private static void FromAmongCaseInsensitive(CliOption> option, string[]? allowedValues = null, string? allowedHiddenValue = null) + private static void FromAmongCaseInsensitive(Option> option, string[]? allowedValues = null, string? allowedHiddenValue = null) { allowedValues ??= []; option.Validators.Add(optionResult => ValidateAllowedValues(optionResult, allowedValues, allowedHiddenValue)); diff --git a/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/localize/LocalizeCommand.cs b/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/localize/LocalizeCommand.cs index 5ba6abbc512..786410b7a15 100644 --- a/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/localize/LocalizeCommand.cs +++ b/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/localize/LocalizeCommand.cs @@ -5,7 +5,7 @@ namespace Microsoft.TemplateEngine.Authoring.CLI.Commands { - internal class LocalizeCommand : CliCommand + internal class LocalizeCommand : Command { internal LocalizeCommand() : base("localize") diff --git a/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/localize/export/ExportCommand.cs b/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/localize/export/ExportCommand.cs index ec7c95b54e3..e2fa5a9c583 100644 --- a/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/localize/export/ExportCommand.cs +++ b/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/localize/export/ExportCommand.cs @@ -11,25 +11,25 @@ internal sealed class ExportCommand : ExecutableCommand { private const string CommandName = "export"; - private readonly CliArgument> _templatePathArgument = new("template-path") + private readonly Argument> _templatePathArgument = new("template-path") { Arity = ArgumentArity.OneOrMore, Description = LocalizableStrings.command_export_help_templatePath_description, }; - private readonly CliOption> _languageOption = new("--language", "-l") + private readonly Option> _languageOption = new("--language", "-l") { Description = LocalizableStrings.command_export_help_language_description, Arity = ArgumentArity.OneOrMore, AllowMultipleArgumentsPerToken = true, }; - private readonly CliOption _recursiveOption = new("recursive", new[] { "--recursive", "-r" }) + private readonly Option _recursiveOption = new("recursive", new[] { "--recursive", "-r" }) { Description = LocalizableStrings.command_export_help_recursive_description, }; - private readonly CliOption _dryRunOption = new("--dry-run", "-d") + private readonly Option _dryRunOption = new("--dry-run", "-d") { Description = LocalizableStrings.command_export_help_dryrun_description, }; diff --git a/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/validate/ValidateCommand.cs b/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/validate/ValidateCommand.cs index 1d4d9a61e62..0fdc8abef0f 100644 --- a/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/validate/ValidateCommand.cs +++ b/tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/validate/ValidateCommand.cs @@ -14,7 +14,7 @@ internal class ValidateCommand : ExecutableCommand { private const string CommandName = "validate"; - private readonly CliArgument _templateLocationArg = new("template-location") + private readonly Argument _templateLocationArg = new("template-location") { Description = LocalizableStrings.command_validate_help_description, Arity = new ArgumentArity(1, 1) diff --git a/tools/Microsoft.TemplateEngine.Authoring.CLI/Program.cs b/tools/Microsoft.TemplateEngine.Authoring.CLI/Program.cs index 2d9ca2b5a91..cca23cfff06 100644 --- a/tools/Microsoft.TemplateEngine.Authoring.CLI/Program.cs +++ b/tools/Microsoft.TemplateEngine.Authoring.CLI/Program.cs @@ -11,7 +11,7 @@ internal sealed class Program { internal static Task Main(string[] args) { - CliRootCommand rootCommand = new("dotnet-template-authoring"); + RootCommand rootCommand = new("dotnet-template-authoring"); rootCommand.Subcommands.Add(new LocalizeCommand()); rootCommand.Subcommands.Add(new VerifyCommand()); rootCommand.Subcommands.Add(new ValidateCommand()); @@ -19,9 +19,9 @@ internal static Task Main(string[] args) return GetCommandLineConfiguration(rootCommand).InvokeAsync(args); } - internal static CliConfiguration GetCommandLineConfiguration(CliCommand command) + internal static CommandLineConfiguration GetCommandLineConfiguration(Command command) { - return new CliConfiguration(command) + return new CommandLineConfiguration(command) { EnablePosixBundling = false }; diff --git a/tools/Microsoft.TemplateSearch.TemplateDiscovery/Program.cs b/tools/Microsoft.TemplateSearch.TemplateDiscovery/Program.cs index a0dfb840a1b..50ffae76938 100644 --- a/tools/Microsoft.TemplateSearch.TemplateDiscovery/Program.cs +++ b/tools/Microsoft.TemplateSearch.TemplateDiscovery/Program.cs @@ -9,7 +9,7 @@ internal class Program { private static async Task Main(string[] args) { - CliCommand rootCommand = new TemplateDiscoveryCommand(); + Command rootCommand = new TemplateDiscoveryCommand(); return await rootCommand.Parse(args).InvokeAsync().ConfigureAwait(false); } } diff --git a/tools/Microsoft.TemplateSearch.TemplateDiscovery/TemplateDiscoveryCommand.cs b/tools/Microsoft.TemplateSearch.TemplateDiscovery/TemplateDiscoveryCommand.cs index e86c59ee489..c3741b35f9a 100644 --- a/tools/Microsoft.TemplateSearch.TemplateDiscovery/TemplateDiscoveryCommand.cs +++ b/tools/Microsoft.TemplateSearch.TemplateDiscovery/TemplateDiscoveryCommand.cs @@ -9,77 +9,77 @@ namespace Microsoft.TemplateSearch.TemplateDiscovery { - internal class TemplateDiscoveryCommand : CliCommand + internal class TemplateDiscoveryCommand : Command { private const int DefaultPageSize = 100; - private readonly CliOption _basePathOption = new("--basePath") + private readonly Option _basePathOption = new("--basePath") { Arity = ArgumentArity.ExactlyOne, Description = "The root dir for output for this run.", Required = true }; - private readonly CliOption _allowPreviewPacksOption = new("--allowPreviewPacks") + private readonly Option _allowPreviewPacksOption = new("--allowPreviewPacks") { Description = "Include preview packs in the results (by default, preview packs are ignored and the latest stable pack is used.", }; - private readonly CliOption _pageSizeOption = new("--pageSize") + private readonly Option _pageSizeOption = new("--pageSize") { Description = "(debugging) The chunk size for interactions with the source.", DefaultValueFactory = (r) => DefaultPageSize, }; - private readonly CliOption _onePageOption = new("--onePage") + private readonly Option _onePageOption = new("--onePage") { Description = "(debugging) Only process one page of template packs.", }; - private readonly CliOption _savePacksOption = new("--savePacks") + private readonly Option _savePacksOption = new("--savePacks") { Description = "Don't delete downloaded candidate packs (by default, they're deleted at the end of a run).", }; - private readonly CliOption _noTemplateJsonFilterOption = new("--noTemplateJsonFilter") + private readonly Option _noTemplateJsonFilterOption = new("--noTemplateJsonFilter") { Description = "Don't prefilter packs that don't contain any template.json files (this filter is applied by default).", }; - private readonly CliOption _verboseOption = new("--verbose", "-v") + private readonly Option _verboseOption = new("--verbose", "-v") { Description = "Verbose output for template processing.", }; - private readonly CliOption _testOption = new("--test", "-t") + private readonly Option _testOption = new("--test", "-t") { Description = "Run tests on generated metadata files.", }; - private readonly CliOption _queriesOption = new("--queries") + private readonly Option _queriesOption = new("--queries") { Arity = ArgumentArity.OneOrMore, Description = $"The list of providers to run. Supported providers: {string.Join(",", Enum.GetValues())}.", AllowMultipleArgumentsPerToken = true, }; - private readonly CliOption _packagesPathOption = new CliOption("--packagesPath") + private readonly Option _packagesPathOption = new Option("--packagesPath") { Description = "Path to pre-downloaded packages. If specified, the packages won't be downloaded from NuGet.org." }.AcceptExistingOnly(); - private readonly CliOption _diffOption = new("--diff") + private readonly Option _diffOption = new("--diff") { Description = "The list of packages will be compared with previous run, and if package version is not changed, the package won't be rescanned.", DefaultValueFactory = (r) => true, }; - private readonly CliOption _diffOverrideCacheOption = new CliOption("--diff-override-cache") + private readonly Option _diffOverrideCacheOption = new Option("--diff-override-cache") { Description = "Location of current search cache (local path only).", }.AcceptExistingOnly(); - private readonly CliOption _diffOverrideNonPackagesOption = new CliOption("--diff-override-non-packages") + private readonly Option _diffOverrideNonPackagesOption = new Option("--diff-override-non-packages") { Description = "Location of the list of packages known not to be a valid package (local path only).", }.AcceptExistingOnly();