Skip to content

Commit 060374e

Browse files
adamsitnikjonsequitur
authored andcommitted
Cli prefix changes:
- remove it for symbol types - replace it with full word CommandLine for Action, Parser and Configuration
1 parent 3bbb940 commit 060374e

File tree

126 files changed

+2583
-2583
lines changed

Some content is hidden

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

126 files changed

+2583
-2583
lines changed

samples/HostingPlayground/Program.cs

Lines changed: 4 additions & 4 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 CliConfiguration BuildCommandLine()
25+
private static CommandLineConfiguration BuildCommandLine()
2626
{
27-
var root = new CliRootCommand(@"$ dotnet run --name 'Joe'"){
28-
new CliOption<string>("--name"){
27+
var root = new RootCommand(@"$ dotnet run --name 'Joe'"){
28+
new Option<string>("--name"){
2929
Required = true
3030
}
3131
};
3232
root.Action = CommandHandler.Create<GreeterOptions, IHost>(Run);
33-
return new CliConfiguration(root);
33+
return new CommandLineConfiguration(root);
3434
}
3535

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

src/Common/ArgumentBuilder.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ internal static class ArgumentBuilder
99

1010
static ArgumentBuilder()
1111
{
12-
_ctor = typeof(CliArgument<string>).GetConstructor(new[] { typeof(string) });
12+
_ctor = typeof(Argument<string>).GetConstructor(new[] { typeof(string) });
1313
}
1414

15-
public static CliArgument CreateArgument(Type valueType, string name = "value")
15+
public static Argument CreateArgument(Type valueType, string name = "value")
1616
{
17-
var argumentType = typeof(CliArgument<>).MakeGenericType(valueType);
17+
var argumentType = typeof(Argument<>).MakeGenericType(valueType);
1818

1919
#if NET6_0_OR_GREATER
2020
var ctor = (ConstructorInfo)argumentType.GetMemberWithSameMetadataDefinitionAs(_ctor);
2121
#else
2222
var ctor = argumentType.GetConstructor(new[] { typeof(string) });
2323
#endif
2424

25-
return (CliArgument)ctor.Invoke(new object[] { name });
25+
return (Argument)ctor.Invoke(new object[] { name });
2626
}
2727

28-
internal static CliArgument CreateArgument(ParameterInfo argsParam)
28+
internal static Argument CreateArgument(ParameterInfo argsParam)
2929
{
3030
if (!argsParam.HasDefaultValue)
3131
{
@@ -36,10 +36,10 @@ internal static CliArgument CreateArgument(ParameterInfo argsParam)
3636

3737
var ctor = argumentType.GetConstructor(new[] { typeof(string), argsParam.ParameterType });
3838

39-
return (CliArgument)ctor.Invoke(new object[] { argsParam.Name, argsParam.DefaultValue });
39+
return (Argument)ctor.Invoke(new object[] { argsParam.Name, argsParam.DefaultValue });
4040
}
4141

42-
private sealed class Bridge<T> : CliArgument<T>
42+
private sealed class Bridge<T> : Argument<T>
4343
{
4444
public Bridge(string name, T defaultValue)
4545
: base(name)

src/Common/OptionBuilder.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@ internal static class OptionBuilder
1111

1212
static OptionBuilder()
1313
{
14-
_ctor = typeof(CliOption<string>).GetConstructor(new[] { typeof(string), typeof(string[]) });
14+
_ctor = typeof(Option<string>).GetConstructor(new[] { typeof(string), typeof(string[]) });
1515
}
1616

17-
internal static CliOption CreateOption(string name, Type valueType, string description = null)
17+
internal static Option CreateOption(string name, Type valueType, string description = null)
1818
{
19-
var optionType = typeof(CliOption<>).MakeGenericType(valueType);
19+
var optionType = typeof(Option<>).MakeGenericType(valueType);
2020

2121
#if NET6_0_OR_GREATER
2222
var ctor = (ConstructorInfo)optionType.GetMemberWithSameMetadataDefinitionAs(_ctor);
2323
#else
2424
var ctor = optionType.GetConstructor(new[] { typeof(string), typeof(string[]) });
2525
#endif
2626

27-
var option = (CliOption)ctor.Invoke(new object[] { name, Array.Empty<string>() });
27+
var option = (Option)ctor.Invoke(new object[] { name, Array.Empty<string>() });
2828

2929
option.Description = description;
3030

3131
return option;
3232
}
3333

34-
internal static CliOption CreateOption(string name, Type valueType, string description, Func<object> defaultValueFactory)
34+
internal static Option CreateOption(string name, Type valueType, string description, Func<object> defaultValueFactory)
3535
{
3636
if (defaultValueFactory == null)
3737
{
@@ -42,12 +42,12 @@ internal static CliOption CreateOption(string name, Type valueType, string descr
4242

4343
var ctor = optionType.GetConstructor(new[] { typeof(string), typeof(Func<object>), typeof(string) });
4444

45-
var option = (CliOption)ctor.Invoke(new object[] { name, defaultValueFactory, description });
45+
var option = (Option)ctor.Invoke(new object[] { name, defaultValueFactory, description });
4646

4747
return option;
4848
}
4949

50-
private sealed class Bridge<T> : CliOption<T>
50+
private sealed class Bridge<T> : Option<T>
5151
{
5252
public Bridge(string name, Func<object> defaultValueFactory, string description)
5353
: base(name)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ System.CommandLine.Hosting
44
public static Microsoft.Extensions.Hosting.IHost GetHost(this System.CommandLine.ParseResult parseResult)
55
public static System.CommandLine.ParseResult GetParseResult(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder)
66
public static System.CommandLine.ParseResult GetParseResult(this Microsoft.Extensions.Hosting.HostBuilderContext context)
7-
public static System.CommandLine.CliCommand UseCommandHandler<THandler>(this System.CommandLine.CliCommand command)
8-
public static System.CommandLine.CliConfiguration UseHost(this System.CommandLine.CliConfiguration config, System.Action<Microsoft.Extensions.Hosting.IHostBuilder> configureHost = null)
9-
public static System.CommandLine.CliConfiguration UseHost(this System.CommandLine.CliConfiguration config, System.Func<System.String[],Microsoft.Extensions.Hosting.IHostBuilder> hostBuilderFactory, System.Action<Microsoft.Extensions.Hosting.IHostBuilder> configureHost = null)
7+
public static System.CommandLine.Command UseCommandHandler<THandler>(this System.CommandLine.Command command)
8+
public static System.CommandLine.CommandLineConfiguration UseHost(this System.CommandLine.CommandLineConfiguration config, System.Action<Microsoft.Extensions.Hosting.IHostBuilder> configureHost = null)
9+
public static System.CommandLine.CommandLineConfiguration UseHost(this System.CommandLine.CommandLineConfiguration config, System.Func<System.String[],Microsoft.Extensions.Hosting.IHostBuilder> hostBuilderFactory, System.Action<Microsoft.Extensions.Hosting.IHostBuilder> configureHost = null)
1010
public static Microsoft.Extensions.Hosting.IHostBuilder UseInvocationLifetime(this Microsoft.Extensions.Hosting.IHostBuilder host, System.Action<InvocationLifetimeOptions> configureOptions = null)
1111
public class InvocationLifetime, Microsoft.Extensions.Hosting.IHostLifetime
1212
.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_NamingConventionBinder_api_is_not_changed.approved.txt

Lines changed: 5 additions & 5 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.Invocation.AsynchronousCliAction
24+
public abstract class BindingHandler : System.CommandLine.Invocation.AsynchronousCommandLineAction
2525
public System.CommandLine.Binding.BindingContext GetBindingContext(System.CommandLine.ParseResult parseResult)
2626
public static class CommandHandler
2727
public static BindingHandler Create(System.Delegate delegate)
@@ -109,16 +109,16 @@ System.CommandLine.NamingConventionBinder
109109
public System.Boolean EnforceExplicitBinding { get; set; }
110110
public ModelDescriptor ModelDescriptor { get; }
111111
public System.CommandLine.Binding.IValueDescriptor ValueDescriptor { get; }
112-
public System.Void BindMemberFromValue(System.Reflection.PropertyInfo property, System.CommandLine.CliSymbol symbol)
112+
public System.Void BindMemberFromValue(System.Reflection.PropertyInfo property, System.CommandLine.Symbol symbol)
113113
public System.Object CreateInstance(System.CommandLine.Binding.BindingContext bindingContext)
114114
public System.Void UpdateInstance<T>(T instance, System.CommandLine.Binding.BindingContext bindingContext)
115115
public class ModelBinder<TModel> : ModelBinder
116116
.ctor()
117-
public System.Void BindMemberFromValue<TValue>(Expression<Func<TModel,TValue>> property, System.CommandLine.CliSymbol symbol)
117+
public System.Void BindMemberFromValue<TValue>(Expression<Func<TModel,TValue>> property, System.CommandLine.Symbol symbol)
118118
public System.Void BindMemberFromValue<TValue>(Expression<Func<TModel,TValue>> property, Func<System.CommandLine.Binding.BindingContext,TValue> getValue)
119119
public class ModelBindingCommandHandler : BindingHandler
120-
public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.CliArgument argument)
121-
public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.CliOption option)
120+
public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.Argument argument)
121+
public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.Option option)
122122
public System.Threading.Tasks.Task<System.Int32> InvokeAsync(System.CommandLine.ParseResult parseResult, System.Threading.CancellationToken cancellationToken = null)
123123
public class ModelDescriptor
124124
public static ModelDescriptor FromType<T>()

0 commit comments

Comments
 (0)