Skip to content

Commit 6a1b077

Browse files
authored
rename Parser to CliParser and CommandLineConfiguration to CliConfiguration (#2136)
1 parent 403234a commit 6a1b077

File tree

57 files changed

+266
-266
lines changed

Some content is hidden

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

57 files changed

+266
-266
lines changed

samples/HostingPlayground/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ static Task Main(string[] args) => BuildCommandLine()
2222
})
2323
.InvokeAsync(args);
2424

25-
private static CommandLineConfiguration BuildCommandLine()
25+
private static CliConfiguration BuildCommandLine()
2626
{
2727
var root = new CliRootCommand(@"$ dotnet run --name 'Joe'"){
2828
new CliOption<string>("--name"){
2929
Required = true
3030
}
3131
};
3232
root.Action = CommandHandler.Create<GreeterOptions, IHost>(Run);
33-
return new CommandLineConfiguration(root);
33+
return new CliConfiguration(root);
3434
}
3535

3636
private static void Run(GreeterOptions options, IHost host)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ System.CommandLine.Hosting
77
public static System.CommandLine.ParseResult GetParseResult(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder)
88
public static System.CommandLine.ParseResult GetParseResult(this Microsoft.Extensions.Hosting.HostBuilderContext context)
99
public static System.CommandLine.CliCommand UseCommandHandler<THandler>(this System.CommandLine.CliCommand command)
10-
public static System.CommandLine.CommandLineConfiguration UseHost(this System.CommandLine.CommandLineConfiguration builder, System.Action<Microsoft.Extensions.Hosting.IHostBuilder> configureHost = null)
11-
public static System.CommandLine.CommandLineConfiguration UseHost(this System.CommandLine.CommandLineConfiguration builder, System.Func<System.String[],Microsoft.Extensions.Hosting.IHostBuilder> hostBuilderFactory, System.Action<Microsoft.Extensions.Hosting.IHostBuilder> configureHost = null)
10+
public static System.CommandLine.CliConfiguration UseHost(this System.CommandLine.CliConfiguration builder, System.Action<Microsoft.Extensions.Hosting.IHostBuilder> configureHost = null)
11+
public static System.CommandLine.CliConfiguration UseHost(this System.CommandLine.CliConfiguration builder, System.Func<System.String[],Microsoft.Extensions.Hosting.IHostBuilder> hostBuilderFactory, System.Action<Microsoft.Extensions.Hosting.IHostBuilder> configureHost = null)
1212
public static Microsoft.Extensions.Hosting.IHostBuilder UseInvocationLifetime(this Microsoft.Extensions.Hosting.IHostBuilder host, System.Action<InvocationLifetimeOptions> configureOptions = null)
1313
public class InvocationLifetime, Microsoft.Extensions.Hosting.IHostLifetime
1414
.ctor(Microsoft.Extensions.Options.IOptions<InvocationLifetimeOptions> options, Microsoft.Extensions.Hosting.IHostEnvironment environment, Microsoft.Extensions.Hosting.IHostApplicationLifetime applicationLifetime, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory = null)

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

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,31 @@ System.CommandLine
5151
public System.Void Add(CliSymbol symbol)
5252
public System.Collections.Generic.IEnumerable<System.CommandLine.Completions.CompletionItem> GetCompletions(System.CommandLine.Completions.CompletionContext context)
5353
public System.Collections.Generic.IEnumerator<CliSymbol> GetEnumerator()
54-
public ParseResult Parse(System.Collections.Generic.IReadOnlyList<System.String> args, CommandLineConfiguration configuration = null)
55-
public ParseResult Parse(System.String commandLine, CommandLineConfiguration configuration = null)
54+
public ParseResult Parse(System.Collections.Generic.IReadOnlyList<System.String> args, CliConfiguration configuration = null)
55+
public ParseResult Parse(System.String commandLine, CliConfiguration configuration = null)
5656
public System.Void SetAction(System.Action<ParseResult> action)
5757
public System.Void SetAction(System.Func<ParseResult,System.Int32> action)
5858
public System.Void SetAction(System.Func<ParseResult,System.Threading.CancellationToken,System.Threading.Tasks.Task> action)
5959
public System.Void SetAction(System.Func<ParseResult,System.Threading.CancellationToken,System.Threading.Tasks.Task<System.Int32>> action)
60+
public class CliConfiguration
61+
.ctor(CliCommand rootCommand)
62+
public System.Collections.Generic.List<CliDirective> Directives { get; }
63+
public System.Boolean EnableDefaultExceptionHandler { get; set; }
64+
public System.Boolean EnableParseErrorReporting { get; set; }
65+
public System.Boolean EnablePosixBundling { get; set; }
66+
public System.Boolean EnableTypoCorrections { get; set; }
67+
public System.IO.TextWriter Error { get; set; }
68+
public System.IO.TextWriter Output { get; set; }
69+
public System.Nullable<System.TimeSpan> ProcessTerminationTimeout { get; set; }
70+
public System.CommandLine.Parsing.TryReplaceToken ResponseFileTokenReplacer { get; set; }
71+
public CliCommand RootCommand { get; }
72+
public System.Int32 Invoke(System.String commandLine)
73+
public System.Int32 Invoke(System.String[] args)
74+
public System.Threading.Tasks.Task<System.Int32> InvokeAsync(System.String commandLine, System.Threading.CancellationToken cancellationToken = null)
75+
public System.Threading.Tasks.Task<System.Int32> InvokeAsync(System.String[] args, System.Threading.CancellationToken cancellationToken = null)
76+
public ParseResult Parse(System.Collections.Generic.IReadOnlyList<System.String> args)
77+
public ParseResult Parse(System.String commandLine)
78+
public System.Void ThrowIfInvalid()
6079
public class CliDirective : CliSymbol
6180
.ctor(System.String name)
6281
public CliAction Action { get; set; }
@@ -92,25 +111,6 @@ System.CommandLine
92111
public System.Collections.Generic.IEnumerable<CliSymbol> Parents { get; }
93112
public System.Collections.Generic.IEnumerable<System.CommandLine.Completions.CompletionItem> GetCompletions(System.CommandLine.Completions.CompletionContext context)
94113
public System.String ToString()
95-
public class CommandLineConfiguration
96-
.ctor(CliCommand rootCommand)
97-
public System.Collections.Generic.List<CliDirective> Directives { get; }
98-
public System.Boolean EnableDefaultExceptionHandler { get; set; }
99-
public System.Boolean EnableParseErrorReporting { get; set; }
100-
public System.Boolean EnablePosixBundling { get; set; }
101-
public System.Boolean EnableTypoCorrections { get; set; }
102-
public System.IO.TextWriter Error { get; set; }
103-
public System.IO.TextWriter Output { get; set; }
104-
public System.Nullable<System.TimeSpan> ProcessTerminationTimeout { get; set; }
105-
public System.CommandLine.Parsing.TryReplaceToken ResponseFileTokenReplacer { get; set; }
106-
public CliCommand RootCommand { get; }
107-
public System.Int32 Invoke(System.String commandLine)
108-
public System.Int32 Invoke(System.String[] args)
109-
public System.Threading.Tasks.Task<System.Int32> InvokeAsync(System.String commandLine, System.Threading.CancellationToken cancellationToken = null)
110-
public System.Threading.Tasks.Task<System.Int32> InvokeAsync(System.String[] args, System.Threading.CancellationToken cancellationToken = null)
111-
public ParseResult Parse(System.Collections.Generic.IReadOnlyList<System.String> args)
112-
public ParseResult Parse(System.String commandLine)
113-
public System.Void ThrowIfInvalid()
114114
public class CommandLineConfigurationException : System.Exception, System.Runtime.Serialization.ISerializable
115115
.ctor(System.String message)
116116
public static class CompletionSourceExtensions
@@ -131,7 +131,7 @@ System.CommandLine
131131
public class ParseResult
132132
public CliAction Action { get; }
133133
public System.CommandLine.Parsing.CommandResult CommandResult { get; }
134-
public CommandLineConfiguration Configuration { get; }
134+
public CliConfiguration Configuration { get; }
135135
public System.Collections.Generic.IReadOnlyList<System.CommandLine.Parsing.ParseError> Errors { get; }
136136
public System.CommandLine.Parsing.CommandResult RootCommandResult { get; }
137137
public System.Collections.Generic.IReadOnlyList<System.CommandLine.Parsing.Token> Tokens { get; }
@@ -234,6 +234,10 @@ System.CommandLine.Parsing
234234
public T GetValueOrDefault<T>()
235235
public System.Void OnlyTake(System.Int32 numberOfTokens)
236236
public System.String ToString()
237+
public static class CliParser
238+
public static System.CommandLine.ParseResult Parse(System.CommandLine.CliCommand command, System.Collections.Generic.IReadOnlyList<System.String> args, System.CommandLine.CliConfiguration configuration = null)
239+
public static System.CommandLine.ParseResult Parse(System.CommandLine.CliCommand command, System.String commandLine, System.CommandLine.CliConfiguration configuration = null)
240+
public static System.Collections.Generic.IEnumerable<System.String> SplitCommandLine(System.String commandLine)
237241
public class CommandResult : SymbolResult
238242
public System.Collections.Generic.IEnumerable<SymbolResult> Children { get; }
239243
public System.CommandLine.CliCommand Command { get; }
@@ -253,10 +257,6 @@ System.CommandLine.Parsing
253257
public System.String Message { get; }
254258
public SymbolResult SymbolResult { get; }
255259
public System.String ToString()
256-
public static class Parser
257-
public static System.CommandLine.ParseResult Parse(System.CommandLine.CliCommand command, System.Collections.Generic.IReadOnlyList<System.String> args, System.CommandLine.CommandLineConfiguration configuration = null)
258-
public static System.CommandLine.ParseResult Parse(System.CommandLine.CliCommand command, System.String commandLine, System.CommandLine.CommandLineConfiguration configuration = null)
259-
public static System.Collections.Generic.IEnumerable<System.String> SplitCommandLine(System.String commandLine)
260260
public abstract class SymbolResult
261261
public SymbolResult Parent { get; }
262262
public System.Collections.Generic.IReadOnlyList<Token> Tokens { get; }

src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_CustomScenarios.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
namespace System.CommandLine.Benchmarks.CommandLine
88
{
99
/// <summary>
10-
/// Measures the performance of <see cref="Parser"/> for custom scenarios.
10+
/// Measures the performance of <see cref="CliParser"/> for custom scenarios.
1111
/// </summary>
1212
[BenchmarkCategory(Categories.CommandLine)]
1313
public class Perf_Parser_CustomScenarios
1414
{
1515
private string _testSymbolsAsString;
1616
private CliCommand _rootCommand;
17-
private CommandLineConfiguration _configuration;
17+
private CliConfiguration _configuration;
1818

1919
[GlobalSetup(Target = nameof(OneOptWithNestedCommand_Parse))]
2020
public void SetupOneOptWithNestedCommand()
@@ -26,7 +26,7 @@ public void SetupOneOptWithNestedCommand()
2626
_rootCommand.Subcommands.Add(nestedCommand);
2727

2828
_testSymbolsAsString = "root_command nested_command -opt1 321";
29-
_configuration = new CommandLineConfiguration(_rootCommand);
29+
_configuration = new CliConfiguration(_rootCommand);
3030
}
3131

3232
[Benchmark]

src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Directives_Suggest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace System.CommandLine.Benchmarks.CommandLine
1313
[BenchmarkCategory(Categories.CommandLine)]
1414
public class Perf_Parser_Directives_Suggest
1515
{
16-
private CommandLineConfiguration _configuration;
16+
private CliConfiguration _configuration;
1717

1818
[GlobalSetup]
1919
public void Setup()
@@ -30,7 +30,7 @@ public void Setup()
3030
vegetableOption
3131
};
3232

33-
_configuration = new CommandLineConfiguration(eatCommand)
33+
_configuration = new CliConfiguration(eatCommand)
3434
{
3535
Directives = { new SuggestDirective() },
3636
Output = System.IO.TextWriter.Null

src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_NestedCommands.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
namespace System.CommandLine.Benchmarks.CommandLine
88
{
99
/// <summary>
10-
/// Measures the performance of <see cref="Parser"/> when parsing commands.
10+
/// Measures the performance of <see cref="CliParser"/> when parsing commands.
1111
/// </summary>
1212
[BenchmarkCategory(Categories.CommandLine)]
1313
public class Perf_Parser_NestedCommands
1414
{
1515
private string _testSymbolsAsString;
1616
private CliCommand _rootCommand;
17-
private CommandLineConfiguration _configuration;
17+
private CliConfiguration _configuration;
1818

1919
/// <remarks>
2020
/// 1 - cmd-root
@@ -62,10 +62,10 @@ public void SetupRootCommand()
6262
}
6363

6464
_rootCommand = rootCommand;
65-
_configuration = new CommandLineConfiguration(rootCommand);
65+
_configuration = new CliConfiguration(rootCommand);
6666
}
6767

6868
[Benchmark]
69-
public ParseResult Parser_Parse() => Parser.Parse(_rootCommand, _testSymbolsAsString, _configuration);
69+
public ParseResult Parser_Parse() => CliParser.Parse(_rootCommand, _testSymbolsAsString, _configuration);
7070
}
7171
}

src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Options_Bare.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
namespace System.CommandLine.Benchmarks.CommandLine
1111
{
1212
/// <summary>
13-
/// Measures the performance of <see cref="Parser"/> when parsing options without arguments.
13+
/// Measures the performance of <see cref="CliParser"/> when parsing options without arguments.
1414
/// </summary>
1515
[BenchmarkCategory(Categories.CommandLine)]
1616
public class Perf_Parser_Options_Bare
1717
{
1818
private IEnumerable<CliOption> _testSymbols;
1919
private string _testSymbolsAsString;
20-
private CommandLineConfiguration _testConfiguration;
20+
private CliConfiguration _testConfiguration;
2121

2222
private IEnumerable<CliOption> GenerateTestOptions(int count, ArgumentArity arity)
2323
=> Enumerable.Range(0, count)
@@ -49,7 +49,7 @@ public void SetupTestOptions()
4949
}
5050

5151
[Benchmark]
52-
public CommandLineConfiguration ParserFromOptions_Ctor()
52+
public CliConfiguration ParserFromOptions_Ctor()
5353
{
5454
return _testSymbols.CreateConfiguration();
5555
}

src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Options_With_Arguments.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
namespace System.CommandLine.Benchmarks.CommandLine
1111
{
1212
/// <summary>
13-
/// Measures the performance of <see cref="Parser"/> when parsing options with arguments.
13+
/// Measures the performance of <see cref="CliParser"/> when parsing options with arguments.
1414
/// </summary>
1515
[BenchmarkCategory(Categories.CommandLine)]
1616
public class Perf_Parser_Options_With_Arguments
1717
{
1818
private string _testSymbolsAsString;
19-
private CommandLineConfiguration _configuration;
19+
private CliConfiguration _configuration;
2020

2121
private IEnumerable<CliOption> GenerateTestOptions(int count, ArgumentArity arity)
2222
=> Enumerable.Range(0, count)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ namespace System.CommandLine.Benchmarks.CommandLine
1717
[BenchmarkCategory(Categories.CommandLine)]
1818
public class Perf_Parser_ParseResult
1919
{
20-
private readonly CommandLineConfiguration _configuration;
20+
private readonly CliConfiguration _configuration;
2121
private readonly StringWriter _output;
2222

2323
public Perf_Parser_ParseResult()
2424
{
2525
_output = new StringWriter();
2626
var option = new CliOption<bool>("-opt");
2727

28-
_configuration = new CommandLineConfiguration(new CliRootCommand { option })
28+
_configuration = new CliConfiguration(new CliRootCommand { option })
2929
{
3030
Directives = { new ParseDiagramDirective() },
3131
Output = _output

src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Simple.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ private static CliRootCommand BuildCommand()
4141
return command;
4242
}
4343

44-
private static CommandLineConfiguration BuildMinimalConfig(CliCommand command)
44+
private static CliConfiguration BuildMinimalConfig(CliCommand command)
4545
{
46-
CommandLineConfiguration config = new(command);
46+
CliConfiguration config = new(command);
4747
config.Directives.Clear();
4848
config.EnableDefaultExceptionHandler = false;
4949
config.ProcessTerminationTimeout = null;

src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_TypoCorrection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ namespace System.CommandLine.Benchmarks.CommandLine
1515
[BenchmarkCategory(Categories.CommandLine)]
1616
public class Perf_Parser_TypoCorrection
1717
{
18-
private readonly CommandLineConfiguration _configuration;
18+
private readonly CliConfiguration _configuration;
1919

2020
public Perf_Parser_TypoCorrection()
2121
{
2222
var option = new CliOption<bool>("--0123456789");
2323

24-
_configuration = new CommandLineConfiguration(new CliRootCommand { option })
24+
_configuration = new CliConfiguration(new CliRootCommand { option })
2525
{
2626
EnableTypoCorrections = true,
2727
Output = System.IO.TextWriter.Null

src/System.CommandLine.Benchmarks/Helpers/Utils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ internal static string CreateTestAssemblyInTempFileFromString(string sourceCode,
4444
return pathToAssemblyFile;
4545
}
4646

47-
public static CommandLineConfiguration CreateConfiguration(this IEnumerable<CliOption> symbols)
47+
public static CliConfiguration CreateConfiguration(this IEnumerable<CliOption> symbols)
4848
{
4949
var rootCommand = new CliRootCommand();
5050

@@ -53,7 +53,7 @@ public static CommandLineConfiguration CreateConfiguration(this IEnumerable<CliO
5353
rootCommand.Add(symbol);
5454
}
5555

56-
return new CommandLineConfiguration(rootCommand);
56+
return new CliConfiguration(rootCommand);
5757
}
5858
}
5959
}

0 commit comments

Comments
 (0)