Skip to content

Commit 104bb34

Browse files
authored
Separate CliAction into synchronous and asynchronous types (#2205)
* split CliAction into sync and async types * minor cleanups * Move typo corrections into ParseErrorAction, make it public This also adds properties to the ParseErrorAction to allow toggling help and typo suggestions when there's a parse error. * rename test class * bring back (internal) anonymous CliAction types * generalize precedence of directive actions over option actions * split into separate files, add XML doc comments * rename DiagramAction to ParseDiagramAction * split CompletionAction into a separate file * exclude benchmarks project from .sln * Address PR comments * support non-terminating option actions * reuse IsBoolean() method * update API baseline
1 parent 02fe27c commit 104bb34

File tree

56 files changed

+936
-868
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+936
-868
lines changed

System.CommandLine.sln

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.CommandLine.Renderin
5050
EndProject
5151
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.CommandLine.Rendering.Tests", "src\System.CommandLine.Rendering.Tests\System.CommandLine.Rendering.Tests.csproj", "{9E574595-A9CD-441A-9328-1D4DD5B531E8}"
5252
EndProject
53-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.CommandLine.Benchmarks", "src\System.CommandLine.Benchmarks\System.CommandLine.Benchmarks.csproj", "{C39B0705-993E-43DB-B66A-A37A587F0BF7}"
54-
EndProject
5553
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.CommandLine.Hosting", "src\System.CommandLine.Hosting\System.CommandLine.Hosting.csproj", "{644C4B4A-4A32-4307-9F71-C3BF901FFB66}"
5654
EndProject
5755
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.CommandLine.Hosting.Tests", "src\System.CommandLine.Hosting.Tests\System.CommandLine.Hosting.Tests.csproj", "{39483140-BC26-4CAD-BBAE-3DC76C2F16CF}"
5856
EndProject
5957
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HostingPlayground", "samples\HostingPlayground\HostingPlayground.csproj", "{0BF6958D-9EE3-4623-B3D6-4DA77EAC1906}"
6058
EndProject
61-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.CommandLine.Generator", "src\System.CommandLine.Generator\System.CommandLine.Generator.csproj", "{B0D00128-E41B-4648-9D22-9B91F8F6BF0C}"
62-
EndProject
63-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.CommandLine.Generator.Tests", "src\System.CommandLine.Generator.Tests\System.CommandLine.Generator.Tests.csproj", "{70B98293-2F69-4262-AADD-D3EEE12046A8}"
59+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.CommandLine.Generator.CommandHandler", "src\System.CommandLine.Generator.CommandHandler\System.CommandLine.Generator.CommandHandler.csproj", "{591EF370-7AD7-4624-8B9D-FD15010CA657}"
6460
EndProject
65-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.CommandLine.Generator.CommandHandler", "src\System.CommandLine.Generator.CommandHandler\System.CommandLine.Generator.CommandHandler.csproj", "{591EF370-7AD7-4624-8B9D-FD15010CA657}"
66-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.CommandLine.NamingConventionBinder", "src\System.CommandLine.NamingConventionBinder\System.CommandLine.NamingConventionBinder.csproj", "{10DFE204-B027-49DA-BD77-08ECA18DD357}"
61+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.CommandLine.NamingConventionBinder", "src\System.CommandLine.NamingConventionBinder\System.CommandLine.NamingConventionBinder.csproj", "{10DFE204-B027-49DA-BD77-08ECA18DD357}"
6762
EndProject
68-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.CommandLine.NamingConventionBinder.Tests", "src\System.CommandLine.NamingConventionBinder.Tests\System.CommandLine.NamingConventionBinder.Tests.csproj", "{789A05F2-5EF6-4FE8-9609-4706207E047E}"
63+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.CommandLine.NamingConventionBinder.Tests", "src\System.CommandLine.NamingConventionBinder.Tests\System.CommandLine.NamingConventionBinder.Tests.csproj", "{789A05F2-5EF6-4FE8-9609-4706207E047E}"
6964
EndProject
70-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.CommandLine.ApiCompatibility.Tests", "src\System.CommandLine.ApiCompatibility.Tests\System.CommandLine.ApiCompatibility.Tests.csproj", "{A54EE328-D456-4BAF-A180-84E77E6409AC}"
65+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.CommandLine.ApiCompatibility.Tests", "src\System.CommandLine.ApiCompatibility.Tests\System.CommandLine.ApiCompatibility.Tests.csproj", "{A54EE328-D456-4BAF-A180-84E77E6409AC}"
7166
EndProject
7267
Global
7368
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -199,18 +194,6 @@ Global
199194
{9E574595-A9CD-441A-9328-1D4DD5B531E8}.Release|x64.Build.0 = Release|Any CPU
200195
{9E574595-A9CD-441A-9328-1D4DD5B531E8}.Release|x86.ActiveCfg = Release|Any CPU
201196
{9E574595-A9CD-441A-9328-1D4DD5B531E8}.Release|x86.Build.0 = Release|Any CPU
202-
{C39B0705-993E-43DB-B66A-A37A587F0BF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
203-
{C39B0705-993E-43DB-B66A-A37A587F0BF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
204-
{C39B0705-993E-43DB-B66A-A37A587F0BF7}.Debug|x64.ActiveCfg = Debug|Any CPU
205-
{C39B0705-993E-43DB-B66A-A37A587F0BF7}.Debug|x64.Build.0 = Debug|Any CPU
206-
{C39B0705-993E-43DB-B66A-A37A587F0BF7}.Debug|x86.ActiveCfg = Debug|Any CPU
207-
{C39B0705-993E-43DB-B66A-A37A587F0BF7}.Debug|x86.Build.0 = Debug|Any CPU
208-
{C39B0705-993E-43DB-B66A-A37A587F0BF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
209-
{C39B0705-993E-43DB-B66A-A37A587F0BF7}.Release|Any CPU.Build.0 = Release|Any CPU
210-
{C39B0705-993E-43DB-B66A-A37A587F0BF7}.Release|x64.ActiveCfg = Release|Any CPU
211-
{C39B0705-993E-43DB-B66A-A37A587F0BF7}.Release|x64.Build.0 = Release|Any CPU
212-
{C39B0705-993E-43DB-B66A-A37A587F0BF7}.Release|x86.ActiveCfg = Release|Any CPU
213-
{C39B0705-993E-43DB-B66A-A37A587F0BF7}.Release|x86.Build.0 = Release|Any CPU
214197
{644C4B4A-4A32-4307-9F71-C3BF901FFB66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
215198
{644C4B4A-4A32-4307-9F71-C3BF901FFB66}.Debug|Any CPU.Build.0 = Debug|Any CPU
216199
{644C4B4A-4A32-4307-9F71-C3BF901FFB66}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -247,30 +230,6 @@ Global
247230
{0BF6958D-9EE3-4623-B3D6-4DA77EAC1906}.Release|x64.Build.0 = Release|Any CPU
248231
{0BF6958D-9EE3-4623-B3D6-4DA77EAC1906}.Release|x86.ActiveCfg = Release|Any CPU
249232
{0BF6958D-9EE3-4623-B3D6-4DA77EAC1906}.Release|x86.Build.0 = Release|Any CPU
250-
{B0D00128-E41B-4648-9D22-9B91F8F6BF0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
251-
{B0D00128-E41B-4648-9D22-9B91F8F6BF0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
252-
{B0D00128-E41B-4648-9D22-9B91F8F6BF0C}.Debug|x64.ActiveCfg = Debug|Any CPU
253-
{B0D00128-E41B-4648-9D22-9B91F8F6BF0C}.Debug|x64.Build.0 = Debug|Any CPU
254-
{B0D00128-E41B-4648-9D22-9B91F8F6BF0C}.Debug|x86.ActiveCfg = Debug|Any CPU
255-
{B0D00128-E41B-4648-9D22-9B91F8F6BF0C}.Debug|x86.Build.0 = Debug|Any CPU
256-
{B0D00128-E41B-4648-9D22-9B91F8F6BF0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
257-
{B0D00128-E41B-4648-9D22-9B91F8F6BF0C}.Release|Any CPU.Build.0 = Release|Any CPU
258-
{B0D00128-E41B-4648-9D22-9B91F8F6BF0C}.Release|x64.ActiveCfg = Release|Any CPU
259-
{B0D00128-E41B-4648-9D22-9B91F8F6BF0C}.Release|x64.Build.0 = Release|Any CPU
260-
{B0D00128-E41B-4648-9D22-9B91F8F6BF0C}.Release|x86.ActiveCfg = Release|Any CPU
261-
{B0D00128-E41B-4648-9D22-9B91F8F6BF0C}.Release|x86.Build.0 = Release|Any CPU
262-
{70B98293-2F69-4262-AADD-D3EEE12046A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
263-
{70B98293-2F69-4262-AADD-D3EEE12046A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
264-
{70B98293-2F69-4262-AADD-D3EEE12046A8}.Debug|x64.ActiveCfg = Debug|Any CPU
265-
{70B98293-2F69-4262-AADD-D3EEE12046A8}.Debug|x64.Build.0 = Debug|Any CPU
266-
{70B98293-2F69-4262-AADD-D3EEE12046A8}.Debug|x86.ActiveCfg = Debug|Any CPU
267-
{70B98293-2F69-4262-AADD-D3EEE12046A8}.Debug|x86.Build.0 = Debug|Any CPU
268-
{70B98293-2F69-4262-AADD-D3EEE12046A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
269-
{70B98293-2F69-4262-AADD-D3EEE12046A8}.Release|Any CPU.Build.0 = Release|Any CPU
270-
{70B98293-2F69-4262-AADD-D3EEE12046A8}.Release|x64.ActiveCfg = Release|Any CPU
271-
{70B98293-2F69-4262-AADD-D3EEE12046A8}.Release|x64.Build.0 = Release|Any CPU
272-
{70B98293-2F69-4262-AADD-D3EEE12046A8}.Release|x86.ActiveCfg = Release|Any CPU
273-
{70B98293-2F69-4262-AADD-D3EEE12046A8}.Release|x86.Build.0 = Release|Any CPU
274233
{591EF370-7AD7-4624-8B9D-FD15010CA657}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
275234
{591EF370-7AD7-4624-8B9D-FD15010CA657}.Debug|Any CPU.Build.0 = Debug|Any CPU
276235
{591EF370-7AD7-4624-8B9D-FD15010CA657}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -334,12 +293,9 @@ Global
334293
{8D9A8DCB-DC74-4B3A-B1C6-046C9C4F458E} = {6749FB3E-39DE-4321-A39E-525278E9408D}
335294
{27E3BFFC-4412-4E4C-A656-B9D35B8A0F3E} = {E5B1EC71-0FC4-4FAA-9C65-32D5016FBC45}
336295
{9E574595-A9CD-441A-9328-1D4DD5B531E8} = {E5B1EC71-0FC4-4FAA-9C65-32D5016FBC45}
337-
{C39B0705-993E-43DB-B66A-A37A587F0BF7} = {E5B1EC71-0FC4-4FAA-9C65-32D5016FBC45}
338296
{644C4B4A-4A32-4307-9F71-C3BF901FFB66} = {E5B1EC71-0FC4-4FAA-9C65-32D5016FBC45}
339297
{39483140-BC26-4CAD-BBAE-3DC76C2F16CF} = {E5B1EC71-0FC4-4FAA-9C65-32D5016FBC45}
340298
{0BF6958D-9EE3-4623-B3D6-4DA77EAC1906} = {6749FB3E-39DE-4321-A39E-525278E9408D}
341-
{B0D00128-E41B-4648-9D22-9B91F8F6BF0C} = {E5B1EC71-0FC4-4FAA-9C65-32D5016FBC45}
342-
{70B98293-2F69-4262-AADD-D3EEE12046A8} = {E5B1EC71-0FC4-4FAA-9C65-32D5016FBC45}
343299
{591EF370-7AD7-4624-8B9D-FD15010CA657} = {E5B1EC71-0FC4-4FAA-9C65-32D5016FBC45}
344300
{10DFE204-B027-49DA-BD77-08ECA18DD357} = {E5B1EC71-0FC4-4FAA-9C65-32D5016FBC45}
345301
{789A05F2-5EF6-4FE8-9609-4706207E047E} = {E5B1EC71-0FC4-4FAA-9C65-32D5016FBC45}

System.CommandLine.v3.ncrunchsolution

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<SolutionConfiguration>
2+
<Settings>
3+
<AllowParallelTestExecution>True</AllowParallelTestExecution>
4+
<CustomBuildProperties>
5+
<Value>TargetFrameworks = net7.0</Value>
6+
<Value>TargetFramework = net7.0</Value>
7+
</CustomBuildProperties>
8+
<SolutionConfigured>True</SolutionConfigured>
9+
</Settings>
10+
</SolutionConfiguration>

src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_NamingConventionBinder_api_is_not_changed.approved.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ System.CommandLine.NamingConventionBinder
2121
public static System.Void AddModelBinder(this System.CommandLine.Binding.BindingContext bindingContext, ModelBinder binder)
2222
public static System.CommandLine.Binding.BindingContext GetBindingContext(this System.CommandLine.ParseResult parseResult)
2323
public static ModelBinder GetOrCreateModelBinder(this System.CommandLine.Binding.BindingContext bindingContext, System.CommandLine.Binding.IValueDescriptor valueDescriptor)
24-
public abstract class BindingHandler : System.CommandLine.CliAction
24+
public abstract class BindingHandler : System.CommandLine.Invocation.AsynchronousCliAction
2525
public System.CommandLine.Binding.BindingContext GetBindingContext(System.CommandLine.ParseResult parseResult)
2626
public static class CommandHandler
2727
public static BindingHandler Create(System.Delegate delegate)
@@ -119,7 +119,6 @@ System.CommandLine.NamingConventionBinder
119119
public class ModelBindingCommandHandler : BindingHandler
120120
public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.CliArgument argument)
121121
public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.CliOption option)
122-
public System.Int32 Invoke(System.CommandLine.ParseResult parseResult)
123122
public System.Threading.Tasks.Task<System.Int32> InvokeAsync(System.CommandLine.ParseResult parseResult, System.Threading.CancellationToken cancellationToken = null)
124123
public class ModelDescriptor
125124
public static ModelDescriptor FromType<T>()

src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ System.CommandLine
1616
public static CliArgument<System.IO.DirectoryInfo> AcceptExistingOnly(this CliArgument<System.IO.DirectoryInfo> argument)
1717
public static CliArgument<System.IO.FileSystemInfo> AcceptExistingOnly(this CliArgument<System.IO.FileSystemInfo> argument)
1818
public static CliArgument<T> AcceptExistingOnly<T>(this CliArgument<T> argument)
19-
public abstract class CliAction
20-
public System.Boolean Exclusive { get; }
21-
public System.Int32 Invoke(ParseResult parseResult)
22-
public System.Threading.Tasks.Task<System.Int32> InvokeAsync(ParseResult parseResult, System.Threading.CancellationToken cancellationToken = null)
23-
protected System.Void set_Exclusive(System.Boolean value)
2419
public abstract class CliArgument : CliSymbol
2520
public ArgumentArity Arity { get; set; }
2621
public System.Collections.Generic.List<System.Func<System.CommandLine.Completions.CompletionContext,System.Collections.Generic.IEnumerable<System.CommandLine.Completions.CompletionItem>>> CompletionSources { get; }
@@ -42,15 +37,17 @@ System.CommandLine
4237
public System.Void AcceptOnlyFromAmong(System.String[] values)
4338
public class CliCommand : CliSymbol, System.Collections.Generic.IEnumerable<CliSymbol>, System.Collections.IEnumerable
4439
.ctor(System.String name, System.String description = null)
45-
public CliAction Action { get; set; }
40+
public System.CommandLine.Invocation.CliAction Action { get; set; }
4641
public System.Collections.Generic.ICollection<System.String> Aliases { get; }
4742
public System.Collections.Generic.IList<CliArgument> Arguments { get; }
4843
public System.Collections.Generic.IEnumerable<CliSymbol> Children { get; }
4944
public System.Collections.Generic.IList<CliOption> Options { get; }
5045
public System.Collections.Generic.IList<CliCommand> Subcommands { get; }
5146
public System.Boolean TreatUnmatchedTokensAsErrors { get; set; }
5247
public System.Collections.Generic.List<System.Action<System.CommandLine.Parsing.CommandResult>> Validators { get; }
53-
public System.Void Add(CliSymbol symbol)
48+
public System.Void Add(CliArgument argument)
49+
public System.Void Add(CliOption option)
50+
public System.Void Add(CliCommand command)
5451
public System.Collections.Generic.IEnumerable<System.CommandLine.Completions.CompletionItem> GetCompletions(System.CommandLine.Completions.CompletionContext context)
5552
public System.Collections.Generic.IEnumerator<CliSymbol> GetEnumerator()
5653
public ParseResult Parse(System.Collections.Generic.IReadOnlyList<System.String> args, CliConfiguration configuration = null)
@@ -63,9 +60,7 @@ System.CommandLine
6360
.ctor(CliCommand rootCommand)
6461
public System.Collections.Generic.List<CliDirective> Directives { get; }
6562
public System.Boolean EnableDefaultExceptionHandler { get; set; }
66-
public System.Boolean EnableParseErrorReporting { get; set; }
6763
public System.Boolean EnablePosixBundling { get; set; }
68-
public System.Boolean EnableTypoCorrections { get; set; }
6964
public System.IO.TextWriter Error { get; set; }
7065
public System.IO.TextWriter Output { get; set; }
7166
public System.Nullable<System.TimeSpan> ProcessTerminationTimeout { get; set; }
@@ -82,10 +77,10 @@ System.CommandLine
8277
.ctor(System.String message)
8378
public class CliDirective : CliSymbol
8479
.ctor(System.String name)
85-
public CliAction Action { get; set; }
80+
public System.CommandLine.Invocation.CliAction Action { get; set; }
8681
public System.Collections.Generic.IEnumerable<System.CommandLine.Completions.CompletionItem> GetCompletions(System.CommandLine.Completions.CompletionContext context)
8782
public abstract class CliOption : CliSymbol
88-
public CliAction Action { get; set; }
83+
public System.CommandLine.Invocation.CliAction Action { get; set; }
8984
public System.Collections.Generic.ICollection<System.String> Aliases { get; }
9085
public System.Boolean AllowMultipleArgumentsPerToken { get; set; }
9186
public ArgumentArity Arity { get; set; }
@@ -120,18 +115,18 @@ System.CommandLine
120115
public static System.Void Add(this System.Collections.Generic.List<System.Func<System.CommandLine.Completions.CompletionContext,System.Collections.Generic.IEnumerable<System.CommandLine.Completions.CompletionItem>>> completionSources, System.String[] completions)
121116
public class DiagramDirective : CliDirective
122117
.ctor()
123-
public CliAction Action { get; set; }
118+
public System.CommandLine.Invocation.CliAction Action { get; set; }
124119
public System.Int32 ParseErrorReturnValue { get; set; }
125120
public class EnvironmentVariablesDirective : CliDirective
126121
.ctor()
127-
public CliAction Action { get; set; }
122+
public System.CommandLine.Invocation.CliAction Action { get; set; }
128123
public static class OptionValidation
129124
public static CliOption<System.IO.FileInfo> AcceptExistingOnly(this CliOption<System.IO.FileInfo> option)
130125
public static CliOption<System.IO.DirectoryInfo> AcceptExistingOnly(this CliOption<System.IO.DirectoryInfo> option)
131126
public static CliOption<System.IO.FileSystemInfo> AcceptExistingOnly(this CliOption<System.IO.FileSystemInfo> option)
132127
public static CliOption<T> AcceptExistingOnly<T>(this CliOption<T> option)
133128
public class ParseResult
134-
public CliAction Action { get; }
129+
public System.CommandLine.Invocation.CliAction Action { get; }
135130
public System.CommandLine.Parsing.CommandResult CommandResult { get; }
136131
public CliConfiguration Configuration { get; }
137132
public System.Collections.Generic.IReadOnlyList<System.CommandLine.Parsing.ParseError> Errors { get; }
@@ -154,7 +149,7 @@ System.CommandLine
154149
public class VersionOption : CliOption<System.Boolean>
155150
.ctor()
156151
.ctor(System.String name, System.String[] aliases)
157-
public CliAction Action { get; set; }
152+
public System.CommandLine.Invocation.CliAction Action { get; set; }
158153
System.CommandLine.Completions
159154
public class CompletionContext
160155
public static CompletionContext Empty { get; }
@@ -174,17 +169,16 @@ System.CommandLine.Completions
174169
public System.String ToString()
175170
public class SuggestDirective : System.CommandLine.CliDirective
176171
.ctor()
177-
public System.CommandLine.CliAction Action { get; set; }
172+
public System.CommandLine.Invocation.CliAction Action { get; set; }
178173
public class TextCompletionContext : CompletionContext
179174
public System.String CommandLineText { get; }
180175
public System.Int32 CursorPosition { get; }
181176
public TextCompletionContext AtCursorPosition(System.Int32 position)
182177
System.CommandLine.Help
183-
public class HelpAction : System.CommandLine.CliAction
178+
public class HelpAction : System.CommandLine.Invocation.SynchronousCliAction
184179
.ctor()
185180
public HelpBuilder Builder { get; set; }
186181
public System.Int32 Invoke(System.CommandLine.ParseResult parseResult)
187-
public System.Threading.Tasks.Task<System.Int32> InvokeAsync(System.CommandLine.ParseResult parseResult, System.Threading.CancellationToken cancellationToken = null)
188182
public class HelpBuilder
189183
.ctor(System.Int32 maxWidth = 2147483647)
190184
public System.Int32 MaxWidth { get; }
@@ -217,14 +211,27 @@ System.CommandLine.Help
217211
public class HelpOption : System.CommandLine.CliOption<System.Boolean>
218212
.ctor()
219213
.ctor(System.String name, System.String[] aliases)
220-
public System.CommandLine.CliAction Action { get; set; }
214+
public System.CommandLine.Invocation.CliAction Action { get; set; }
221215
public class TwoColumnHelpRow, System.IEquatable<TwoColumnHelpRow>
222216
.ctor(System.String firstColumnText, System.String secondColumnText)
223217
public System.String FirstColumnText { get; }
224218
public System.String SecondColumnText { get; }
225219
public System.Boolean Equals(System.Object obj)
226220
public System.Boolean Equals(TwoColumnHelpRow other)
227221
public System.Int32 GetHashCode()
222+
System.CommandLine.Invocation
223+
public abstract class AsynchronousCliAction : CliAction
224+
public System.Threading.Tasks.Task<System.Int32> InvokeAsync(System.CommandLine.ParseResult parseResult, System.Threading.CancellationToken cancellationToken = null)
225+
public abstract class CliAction
226+
public System.Boolean Terminating { get; }
227+
protected System.Void set_Terminating(System.Boolean value)
228+
public class ParseErrorAction : SynchronousCliAction
229+
.ctor()
230+
public System.Boolean ShowHelp { get; set; }
231+
public System.Boolean ShowTypoCorrections { get; set; }
232+
public System.Int32 Invoke(System.CommandLine.ParseResult parseResult)
233+
public abstract class SynchronousCliAction : CliAction
234+
public System.Int32 Invoke(System.CommandLine.ParseResult parseResult)
228235
System.CommandLine.Parsing
229236
public class ArgumentResult : SymbolResult
230237
public System.CommandLine.CliArgument Argument { get; }

src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_ParseResult.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System.Collections.Generic;
55
using System.CommandLine.Benchmarks.Helpers;
6+
using System.CommandLine.Invocation;
67
using System.IO;
78
using System.Linq;
89
using System.Text;
@@ -60,7 +61,7 @@ public string ParseResult_Diagram(BdnParam<ParseResult> parseResult)
6061
// clear the contents, so each benchmark has the same starting state
6162
stringBuilder.Clear();
6263

63-
parseResult.Value.Action!.Invoke(parseResult.Value);
64+
((SynchronousCliAction)parseResult.Value.Action)!.Invoke(parseResult.Value);
6465

6566
return stringBuilder.ToString();
6667
}
@@ -74,7 +75,7 @@ public async Task<string> ParseResult_DiagramAsync(BdnParam<ParseResult> parseRe
7475
// clear the contents, so each benchmark has the same starting state
7576
stringBuilder.Clear();
7677

77-
await parseResult.Value.Action!.InvokeAsync(parseResult.Value);
78+
await ((AsynchronousCliAction)parseResult.Value.Action!).InvokeAsync(parseResult.Value);
7879

7980
return stringBuilder.ToString();
8081
}

0 commit comments

Comments
 (0)