Skip to content

Commit d92055f

Browse files
[BLOCKED] System.CommandLine update (#8702)
* Update dependencies from https://github.com/dotnet/command-line-api build 20250122.1 System.CommandLine From Version 2.0.0-beta4.25071.2 -> To Version 2.0.0-beta4.25072.1 * remove the Cli prefix to adjust to most recent System.CommandLine breaking changes * Apply suggestions from code review --------- Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
1 parent 7095698 commit d92055f

File tree

11 files changed

+47
-47
lines changed

11 files changed

+47
-47
lines changed

Diff for: eng/Version.Details.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
<Sha>1df7df81ac783e63aa7fbccb0232ad20fb128b15</Sha>
1414
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
1515
</Dependency>
16-
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.25071.2">
16+
<Dependency Name="System.CommandLine" Version="2.0.0-beta5.25208.1">
1717
<Uri>https://github.com/dotnet/command-line-api</Uri>
18-
<Sha>3bbb940ceeb3254790899d751a8d418348563d40</Sha>
18+
<Sha>48bd86bdcd926a194e1581a60d820d12a64ef3c6</Sha>
1919
</Dependency>
2020
</ProductDependencies>
2121
<ToolsetDependencies>

Diff for: eng/Versions.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<PropertyGroup>
1616
<!-- Non-maestro versions -->
1717
<SystemFormatsAsn1Version>9.0.0</SystemFormatsAsn1Version>
18-
<SystemCommandLinePackageVersion>2.0.0-beta4.25071.2</SystemCommandLinePackageVersion>
18+
<SystemCommandLinePackageVersion>2.0.0-beta5.25208.1</SystemCommandLinePackageVersion>
1919
<MicrosoftExtensionsLoggingPackageVersion>9.0.3</MicrosoftExtensionsLoggingPackageVersion>
2020
<MicrosoftExtensionsLoggingAbstractionsPackageVersion>9.0.3</MicrosoftExtensionsLoggingAbstractionsPackageVersion>
2121
<MicrosoftExtensionsLoggingConsolePackageVersion>9.0.3</MicrosoftExtensionsLoggingConsolePackageVersion>

Diff for: test/Microsoft.TemplateEngine.Authoring.CLI.UnitTests/ValidateCommandTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class ValidateCommandTests : TestBase
1212
[Fact]
1313
public async Task ValidateCommand_BasicTest_InvalidTemplate()
1414
{
15-
CliRootCommand root = new()
15+
RootCommand root = new()
1616
{
1717
new ValidateCommand()
1818
};
@@ -26,7 +26,7 @@ public async Task ValidateCommand_BasicTest_InvalidTemplate()
2626
[Fact]
2727
public async Task ValidateCommand_BasicTest_ValidTemplate()
2828
{
29-
CliRootCommand root = new()
29+
RootCommand root = new()
3030
{
3131
new ValidateCommand()
3232
};

Diff for: tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/ExecutableCommand.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
namespace Microsoft.TemplateEngine.Authoring.CLI.Commands
1010
{
1111
/// <summary>
12-
/// Represents a <see cref="CliCommand"/> together with its action.
12+
/// Represents a <see cref="Command"/> together with its action.
1313
/// </summary>
14-
internal abstract class ExecutableCommand<TModel> : CliCommand where TModel : class
14+
internal abstract class ExecutableCommand<TModel> : Command where TModel : class
1515
{
1616
internal ExecutableCommand(string name, string? description = null)
1717
: base(name, description)
@@ -29,7 +29,7 @@ internal ExecutableCommand(string name, string? description = null)
2929
/// </summary>
3030
protected abstract Task<int> ExecuteAsync(TModel args, ILoggerFactory loggerFactory, CancellationToken cancellationToken);
3131

32-
private sealed class CommandAction : AsynchronousCliAction
32+
private sealed class CommandAction : AsynchronousCommandLineAction
3333
{
3434
private readonly ExecutableCommand<TModel> _command;
3535

Diff for: tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/Verify/VerifyCommand.cs

+15-15
Original file line numberDiff line numberDiff line change
@@ -12,72 +12,72 @@ internal class VerifyCommand : ExecutableCommand<VerifyCommandArgs>
1212
{
1313
private const string CommandName = "verify";
1414

15-
private readonly CliArgument<string> _templateNameArgument = new("template-short-name")
15+
private readonly Argument<string> _templateNameArgument = new("template-short-name")
1616
{
1717
Description = LocalizableStrings.command_verify_help_templateName_description,
1818
// 0 for case where only path is specified
1919
Arity = new ArgumentArity(1, 1)
2020
};
2121

22-
private readonly CliOption<string> _remainingArguments = new("--template-args")
22+
private readonly Option<string> _remainingArguments = new("--template-args")
2323
{
2424
Description = "Template specific arguments - all joined into single enquoted string. Any needed quotations of actual arguments has to be escaped.",
2525
Arity = new ArgumentArity(0, 1)
2626
};
2727

28-
private readonly CliOption<string> _templatePathOption = new("--template-path", "-p")
28+
private readonly Option<string> _templatePathOption = new("--template-path", "-p")
2929
{
3030
Description = LocalizableStrings.command_verify_help_templatePath_description,
3131
};
3232

33-
private readonly CliOption<string> _templateOutputPathOption = new("--output", "-o")
33+
private readonly Option<string> _templateOutputPathOption = new("--output", "-o")
3434
{
3535
Description = LocalizableStrings.command_verify_help_outputPath_description,
3636
};
3737

38-
private readonly CliOption<string> _snapshotsDirectoryOption = new("--snapshots-directory", "-d")
38+
private readonly Option<string> _snapshotsDirectoryOption = new("--snapshots-directory", "-d")
3939
{
4040
Description = LocalizableStrings.command_verify_help_snapshotsDirPath_description,
4141
};
4242

43-
private readonly CliOption<string> _scenarioNameOption = new("--scenario-name")
43+
private readonly Option<string> _scenarioNameOption = new("--scenario-name")
4444
{
4545
Description = LocalizableStrings.command_verify_help_scenarioName_description,
4646
};
4747

48-
private readonly CliOption<bool> _disableDiffToolOption = new("--disable-diff-tool")
48+
private readonly Option<bool> _disableDiffToolOption = new("--disable-diff-tool")
4949
{
5050
Description = LocalizableStrings.command_verify_help_disableDiffTool_description,
5151
};
5252

53-
private readonly CliOption<bool> _disableDefaultExcludePatternsOption = new("--disable-default-exclude-patterns")
53+
private readonly Option<bool> _disableDefaultExcludePatternsOption = new("--disable-default-exclude-patterns")
5454
{
5555
Description = LocalizableStrings.command_verify_help_disableDefaultExcludes_description,
5656
};
5757

58-
private readonly CliOption<IEnumerable<string>> _excludePatternOption = new("--exclude-pattern")
58+
private readonly Option<IEnumerable<string>> _excludePatternOption = new("--exclude-pattern")
5959
{
6060
Description = LocalizableStrings.command_verify_help_customExcludes_description,
6161
Arity = new ArgumentArity(0, 999)
6262
};
6363

64-
private readonly CliOption<IEnumerable<string>> _includePatternOption = new("--include-pattern")
64+
private readonly Option<IEnumerable<string>> _includePatternOption = new("--include-pattern")
6565
{
6666
Description = LocalizableStrings.command_verify_help_customIncludes_description,
6767
Arity = new ArgumentArity(0, 999)
6868
};
6969

70-
private readonly CliOption<bool> _verifyCommandOutputOption = new("--verify-std")
70+
private readonly Option<bool> _verifyCommandOutputOption = new("--verify-std")
7171
{
7272
Description = LocalizableStrings.command_verify_help_verifyOutputs_description,
7373
};
7474

75-
private readonly CliOption<bool> _isCommandExpectedToFailOption = new("--fail-expected")
75+
private readonly Option<bool> _isCommandExpectedToFailOption = new("--fail-expected")
7676
{
7777
Description = LocalizableStrings.command_verify_help_expectFailure_description,
7878
};
7979

80-
private readonly CliOption<IEnumerable<UniqueForOption>> _uniqueForOption = new("--unique-for")
80+
private readonly Option<IEnumerable<UniqueForOption>> _uniqueForOption = new("--unique-for")
8181
{
8282
Description = LocalizableStrings.command_verify_help_uniqueFor_description,
8383
Arity = new ArgumentArity(0, 999),
@@ -171,9 +171,9 @@ await engine.Execute(
171171
}
172172

173173
/// <summary>
174-
/// Case insensitive version for <see cref="CliOption{T}.AcceptOnlyFromAmong(string[])"/>.
174+
/// Case insensitive version for <see cref="Option{T}.AcceptOnlyFromAmong(string[])"/>.
175175
/// </summary>
176-
private static void FromAmongCaseInsensitive(CliOption<IEnumerable<UniqueForOption>> option, string[]? allowedValues = null, string? allowedHiddenValue = null)
176+
private static void FromAmongCaseInsensitive(Option<IEnumerable<UniqueForOption>> option, string[]? allowedValues = null, string? allowedHiddenValue = null)
177177
{
178178
allowedValues ??= [];
179179
option.Validators.Add(optionResult => ValidateAllowedValues(optionResult, allowedValues, allowedHiddenValue));

Diff for: tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/localize/LocalizeCommand.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Microsoft.TemplateEngine.Authoring.CLI.Commands
77
{
8-
internal class LocalizeCommand : CliCommand
8+
internal class LocalizeCommand : Command
99
{
1010
internal LocalizeCommand()
1111
: base("localize")

Diff for: tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/localize/export/ExportCommand.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@ internal sealed class ExportCommand : ExecutableCommand<ExportCommandArgs>
1111
{
1212
private const string CommandName = "export";
1313

14-
private readonly CliArgument<IEnumerable<string>> _templatePathArgument = new("template-path")
14+
private readonly Argument<IEnumerable<string>> _templatePathArgument = new("template-path")
1515
{
1616
Arity = ArgumentArity.OneOrMore,
1717
Description = LocalizableStrings.command_export_help_templatePath_description,
1818
};
1919

20-
private readonly CliOption<IEnumerable<string>> _languageOption = new("--language", "-l")
20+
private readonly Option<IEnumerable<string>> _languageOption = new("--language", "-l")
2121
{
2222
Description = LocalizableStrings.command_export_help_language_description,
2323
Arity = ArgumentArity.OneOrMore,
2424
AllowMultipleArgumentsPerToken = true,
2525
};
2626

27-
private readonly CliOption<bool> _recursiveOption = new("recursive", new[] { "--recursive", "-r" })
27+
private readonly Option<bool> _recursiveOption = new("recursive", new[] { "--recursive", "-r" })
2828
{
2929
Description = LocalizableStrings.command_export_help_recursive_description,
3030
};
3131

32-
private readonly CliOption<bool> _dryRunOption = new("--dry-run", "-d")
32+
private readonly Option<bool> _dryRunOption = new("--dry-run", "-d")
3333
{
3434
Description = LocalizableStrings.command_export_help_dryrun_description,
3535
};

Diff for: tools/Microsoft.TemplateEngine.Authoring.CLI/Commands/validate/ValidateCommand.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal class ValidateCommand : ExecutableCommand<ValidateCommandArgs>
1414
{
1515
private const string CommandName = "validate";
1616

17-
private readonly CliArgument<string> _templateLocationArg = new("template-location")
17+
private readonly Argument<string> _templateLocationArg = new("template-location")
1818
{
1919
Description = LocalizableStrings.command_validate_help_description,
2020
Arity = new ArgumentArity(1, 1)

Diff for: tools/Microsoft.TemplateEngine.Authoring.CLI/Program.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ internal sealed class Program
1111
{
1212
internal static Task<int> Main(string[] args)
1313
{
14-
CliRootCommand rootCommand = new("dotnet-template-authoring");
14+
RootCommand rootCommand = new("dotnet-template-authoring");
1515
rootCommand.Subcommands.Add(new LocalizeCommand());
1616
rootCommand.Subcommands.Add(new VerifyCommand());
1717
rootCommand.Subcommands.Add(new ValidateCommand());
1818

1919
return GetCommandLineConfiguration(rootCommand).InvokeAsync(args);
2020
}
2121

22-
internal static CliConfiguration GetCommandLineConfiguration(CliCommand command)
22+
internal static CommandLineConfiguration GetCommandLineConfiguration(Command command)
2323
{
24-
return new CliConfiguration(command)
24+
return new CommandLineConfiguration(command)
2525
{
2626
EnablePosixBundling = false
2727
};

Diff for: tools/Microsoft.TemplateSearch.TemplateDiscovery/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal class Program
99
{
1010
private static async Task<int> Main(string[] args)
1111
{
12-
CliCommand rootCommand = new TemplateDiscoveryCommand();
12+
Command rootCommand = new TemplateDiscoveryCommand();
1313
return await rootCommand.Parse(args).InvokeAsync().ConfigureAwait(false);
1414
}
1515
}

Diff for: tools/Microsoft.TemplateSearch.TemplateDiscovery/TemplateDiscoveryCommand.cs

+14-14
Original file line numberDiff line numberDiff line change
@@ -9,77 +9,77 @@
99

1010
namespace Microsoft.TemplateSearch.TemplateDiscovery
1111
{
12-
internal class TemplateDiscoveryCommand : CliCommand
12+
internal class TemplateDiscoveryCommand : Command
1313
{
1414
private const int DefaultPageSize = 100;
1515

16-
private readonly CliOption<DirectoryInfo> _basePathOption = new("--basePath")
16+
private readonly Option<DirectoryInfo> _basePathOption = new("--basePath")
1717
{
1818
Arity = ArgumentArity.ExactlyOne,
1919
Description = "The root dir for output for this run.",
2020
Required = true
2121
};
2222

23-
private readonly CliOption<bool> _allowPreviewPacksOption = new("--allowPreviewPacks")
23+
private readonly Option<bool> _allowPreviewPacksOption = new("--allowPreviewPacks")
2424
{
2525
Description = "Include preview packs in the results (by default, preview packs are ignored and the latest stable pack is used.",
2626
};
2727

28-
private readonly CliOption<int> _pageSizeOption = new("--pageSize")
28+
private readonly Option<int> _pageSizeOption = new("--pageSize")
2929
{
3030
Description = "(debugging) The chunk size for interactions with the source.",
3131
DefaultValueFactory = (r) => DefaultPageSize,
3232
};
3333

34-
private readonly CliOption<bool> _onePageOption = new("--onePage")
34+
private readonly Option<bool> _onePageOption = new("--onePage")
3535
{
3636
Description = "(debugging) Only process one page of template packs.",
3737
};
3838

39-
private readonly CliOption<bool> _savePacksOption = new("--savePacks")
39+
private readonly Option<bool> _savePacksOption = new("--savePacks")
4040
{
4141
Description = "Don't delete downloaded candidate packs (by default, they're deleted at the end of a run).",
4242
};
4343

44-
private readonly CliOption<bool> _noTemplateJsonFilterOption = new("--noTemplateJsonFilter")
44+
private readonly Option<bool> _noTemplateJsonFilterOption = new("--noTemplateJsonFilter")
4545
{
4646
Description = "Don't prefilter packs that don't contain any template.json files (this filter is applied by default).",
4747
};
4848

49-
private readonly CliOption<bool> _verboseOption = new("--verbose", "-v")
49+
private readonly Option<bool> _verboseOption = new("--verbose", "-v")
5050
{
5151
Description = "Verbose output for template processing.",
5252
};
5353

54-
private readonly CliOption<bool> _testOption = new("--test", "-t")
54+
private readonly Option<bool> _testOption = new("--test", "-t")
5555
{
5656
Description = "Run tests on generated metadata files.",
5757
};
5858

59-
private readonly CliOption<SupportedQueries[]> _queriesOption = new("--queries")
59+
private readonly Option<SupportedQueries[]> _queriesOption = new("--queries")
6060
{
6161
Arity = ArgumentArity.OneOrMore,
6262
Description = $"The list of providers to run. Supported providers: {string.Join(",", Enum.GetValues<SupportedQueries>())}.",
6363
AllowMultipleArgumentsPerToken = true,
6464
};
6565

66-
private readonly CliOption<DirectoryInfo> _packagesPathOption = new CliOption<DirectoryInfo>("--packagesPath")
66+
private readonly Option<DirectoryInfo> _packagesPathOption = new Option<DirectoryInfo>("--packagesPath")
6767
{
6868
Description = "Path to pre-downloaded packages. If specified, the packages won't be downloaded from NuGet.org."
6969
}.AcceptExistingOnly();
7070

71-
private readonly CliOption<bool> _diffOption = new("--diff")
71+
private readonly Option<bool> _diffOption = new("--diff")
7272
{
7373
Description = "The list of packages will be compared with previous run, and if package version is not changed, the package won't be rescanned.",
7474
DefaultValueFactory = (r) => true,
7575
};
7676

77-
private readonly CliOption<FileInfo> _diffOverrideCacheOption = new CliOption<FileInfo>("--diff-override-cache")
77+
private readonly Option<FileInfo> _diffOverrideCacheOption = new Option<FileInfo>("--diff-override-cache")
7878
{
7979
Description = "Location of current search cache (local path only).",
8080
}.AcceptExistingOnly();
8181

82-
private readonly CliOption<FileInfo> _diffOverrideNonPackagesOption = new CliOption<FileInfo>("--diff-override-non-packages")
82+
private readonly Option<FileInfo> _diffOverrideNonPackagesOption = new Option<FileInfo>("--diff-override-non-packages")
8383
{
8484
Description = "Location of the list of packages known not to be a valid package (local path only).",
8585
}.AcceptExistingOnly();

0 commit comments

Comments
 (0)