Skip to content

Commit

Permalink
rename symbol types with Cli prefix; some property renames and file m…
Browse files Browse the repository at this point in the history
…oves (#2132)
  • Loading branch information
jonsequitur committed Mar 31, 2023
1 parent 6706d65 commit 403234a
Show file tree
Hide file tree
Showing 125 changed files with 2,271 additions and 2,259 deletions.
6 changes: 3 additions & 3 deletions samples/HostingPlayground/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ static Task Main(string[] args) => BuildCommandLine()

private static CommandLineConfiguration BuildCommandLine()
{
var root = new RootCommand(@"$ dotnet run --name 'Joe'"){
new Option<string>("--name"){
IsRequired = true
var root = new CliRootCommand(@"$ dotnet run --name 'Joe'"){
new CliOption<string>("--name"){
Required = true
}
};
root.Action = CommandHandler.Create<GreeterOptions, IHost>(Run);
Expand Down
14 changes: 7 additions & 7 deletions src/Common/ArgumentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ internal static class ArgumentBuilder

static ArgumentBuilder()
{
_ctor = typeof(Argument<string>).GetConstructor(new[] { typeof(string) });
_ctor = typeof(CliArgument<string>).GetConstructor(new[] { typeof(string) });
}

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

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

return (Argument)ctor.Invoke(new object[] { name });
return (CliArgument)ctor.Invoke(new object[] { name });
}

internal static Argument CreateArgument(ParameterInfo argsParam)
internal static CliArgument CreateArgument(ParameterInfo argsParam)
{
if (!argsParam.HasDefaultValue)
{
Expand All @@ -36,10 +36,10 @@ internal static Argument CreateArgument(ParameterInfo argsParam)

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

return (Argument)ctor.Invoke(new object[] { argsParam.Name, argsParam.DefaultValue });
return (CliArgument)ctor.Invoke(new object[] { argsParam.Name, argsParam.DefaultValue });
}

private sealed class Bridge<T> : Argument<T>
private sealed class Bridge<T> : CliArgument<T>
{
public Bridge(string name, T defaultValue)
: base(name)
Expand Down
14 changes: 7 additions & 7 deletions src/Common/OptionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ internal static class OptionBuilder

static OptionBuilder()
{
_ctor = typeof(Option<string>).GetConstructor(new[] { typeof(string), typeof(string[]) });
_ctor = typeof(CliOption<string>).GetConstructor(new[] { typeof(string), typeof(string[]) });
}

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

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

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

option.Description = description;

return option;
}

internal static Option CreateOption(string name, Type valueType, string description, Func<object> defaultValueFactory)
internal static CliOption CreateOption(string name, Type valueType, string description, Func<object> defaultValueFactory)
{
if (defaultValueFactory == null)
{
Expand All @@ -42,12 +42,12 @@ internal static Option CreateOption(string name, Type valueType, string descript

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

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

return option;
}

private sealed class Bridge<T> : Option<T>
private sealed class Bridge<T> : CliOption<T>
{
public Bridge(string name, Func<object> defaultValueFactory, string description)
: base(name)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
System.CommandLine.Hosting
public static class DirectiveConfigurationExtensions
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCommandLineDirectives(this Microsoft.Extensions.Configuration.IConfigurationBuilder config, System.CommandLine.ParseResult commandline, System.CommandLine.Directive directive)
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCommandLineDirectives(this Microsoft.Extensions.Configuration.IConfigurationBuilder config, System.CommandLine.ParseResult commandline, System.CommandLine.CliDirective directive)
public static class HostingExtensions
public static OptionsBuilder<TOptions> BindCommandLine<TOptions>(this OptionsBuilder<TOptions> optionsBuilder)
public static Microsoft.Extensions.Hosting.IHost GetHost(this System.CommandLine.ParseResult parseResult)
public static System.CommandLine.ParseResult GetParseResult(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder)
public static System.CommandLine.ParseResult GetParseResult(this Microsoft.Extensions.Hosting.HostBuilderContext context)
public static System.CommandLine.Command UseCommandHandler<THandler>(this System.CommandLine.Command command)
public static System.CommandLine.CliCommand UseCommandHandler<THandler>(this System.CommandLine.CliCommand command)
public static System.CommandLine.CommandLineConfiguration UseHost(this System.CommandLine.CommandLineConfiguration builder, System.Action<Microsoft.Extensions.Hosting.IHostBuilder> configureHost = null)
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)
public static Microsoft.Extensions.Hosting.IHostBuilder UseInvocationLifetime(this Microsoft.Extensions.Hosting.IHostBuilder host, System.Action<InvocationLifetimeOptions> configureOptions = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ System.CommandLine.NamingConventionBinder
public System.Boolean EnforceExplicitBinding { get; set; }
public ModelDescriptor ModelDescriptor { get; }
public System.CommandLine.Binding.IValueDescriptor ValueDescriptor { get; }
public System.Void BindMemberFromValue(System.Reflection.PropertyInfo property, System.CommandLine.Symbol symbol)
public System.Void BindMemberFromValue(System.Reflection.PropertyInfo property, System.CommandLine.CliSymbol symbol)
public System.Object CreateInstance(System.CommandLine.Binding.BindingContext bindingContext)
public System.Void UpdateInstance<T>(T instance, System.CommandLine.Binding.BindingContext bindingContext)
public class ModelBinder<TModel> : ModelBinder
.ctor()
public System.Void BindMemberFromValue<TValue>(Expression<Func<TModel,TValue>> property, System.CommandLine.Symbol symbol)
public System.Void BindMemberFromValue<TValue>(Expression<Func<TModel,TValue>> property, System.CommandLine.CliSymbol symbol)
public System.Void BindMemberFromValue<TValue>(Expression<Func<TModel,TValue>> property, Func<System.CommandLine.Binding.BindingContext,TValue> getValue)
public class ModelBindingCommandHandler : BindingHandler
public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.Argument argument)
public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.Option option)
public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.CliArgument argument)
public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.CliOption option)
public System.Int32 Invoke(System.CommandLine.ParseResult parseResult)
public System.Threading.Tasks.Task<System.Int32> InvokeAsync(System.CommandLine.ParseResult parseResult, System.Threading.CancellationToken cancellationToken = null)
public class ModelDescriptor
Expand Down

0 comments on commit 403234a

Please sign in to comment.