Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions samples/HostingPlayground/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ static Task Main(string[] args) => BuildCommandLine()
})
.InvokeAsync(args);

private static CliConfiguration BuildCommandLine()
private static CommandLineConfiguration BuildCommandLine()
{
var root = new CliRootCommand(@"$ dotnet run --name 'Joe'"){
new CliOption<string>("--name"){
var root = new RootCommand(@"$ dotnet run --name 'Joe'"){
new Option<string>("--name"){
Required = true
}
};
root.Action = CommandHandler.Create<GreeterOptions, IHost>(Run);
return new CliConfiguration(root);
return new CommandLineConfiguration(root);
}

private static void Run(GreeterOptions options, IHost host)
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(CliArgument<string>).GetConstructor(new[] { typeof(string) });
_ctor = typeof(Argument<string>).GetConstructor(new[] { typeof(string) });
}

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

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

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

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

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

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

private sealed class Bridge<T> : CliArgument<T>
private sealed class Bridge<T> : Argument<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(CliOption<string>).GetConstructor(new[] { typeof(string), typeof(string[]) });
_ctor = typeof(Option<string>).GetConstructor(new[] { typeof(string), typeof(string[]) });
}

internal static CliOption CreateOption(string name, Type valueType, string description = null)
internal static Option CreateOption(string name, Type valueType, string description = null)
{
var optionType = typeof(CliOption<>).MakeGenericType(valueType);
var optionType = typeof(Option<>).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 = (CliOption)ctor.Invoke(new object[] { name, Array.Empty<string>() });
var option = (Option)ctor.Invoke(new object[] { name, Array.Empty<string>() });

option.Description = description;

return option;
}

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

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

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

return option;
}

private sealed class Bridge<T> : CliOption<T>
private sealed class Bridge<T> : Option<T>
{
public Bridge(string name, Func<object> defaultValueFactory, string description)
: base(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ System.CommandLine.Hosting
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.CliCommand UseCommandHandler<THandler>(this System.CommandLine.CliCommand command)
public static System.CommandLine.CliConfiguration UseHost(this System.CommandLine.CliConfiguration config, System.Action<Microsoft.Extensions.Hosting.IHostBuilder> configureHost = null)
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)
public static System.CommandLine.Command UseCommandHandler<THandler>(this System.CommandLine.Command command)
public static System.CommandLine.CommandLineConfiguration UseHost(this System.CommandLine.CommandLineConfiguration config, System.Action<Microsoft.Extensions.Hosting.IHostBuilder> configureHost = null)
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)
public static Microsoft.Extensions.Hosting.IHostBuilder UseInvocationLifetime(this Microsoft.Extensions.Hosting.IHostBuilder host, System.Action<InvocationLifetimeOptions> configureOptions = null)
public class InvocationLifetime, Microsoft.Extensions.Hosting.IHostLifetime
.ctor(Microsoft.Extensions.Options.IOptions<InvocationLifetimeOptions> options, Microsoft.Extensions.Hosting.IHostEnvironment environment, Microsoft.Extensions.Hosting.IHostApplicationLifetime applicationLifetime, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ System.CommandLine.NamingConventionBinder
public static System.Void AddModelBinder(this System.CommandLine.Binding.BindingContext bindingContext, ModelBinder binder)
public static System.CommandLine.Binding.BindingContext GetBindingContext(this System.CommandLine.ParseResult parseResult)
public static ModelBinder GetOrCreateModelBinder(this System.CommandLine.Binding.BindingContext bindingContext, System.CommandLine.Binding.IValueDescriptor valueDescriptor)
public abstract class BindingHandler : System.CommandLine.Invocation.AsynchronousCliAction
public abstract class BindingHandler : System.CommandLine.Invocation.AsynchronousCommandLineAction
public System.CommandLine.Binding.BindingContext GetBindingContext(System.CommandLine.ParseResult parseResult)
public static class CommandHandler
public static BindingHandler Create(System.Delegate delegate)
Expand Down 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.CliSymbol symbol)
public System.Void BindMemberFromValue(System.Reflection.PropertyInfo property, System.CommandLine.Symbol 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.CliSymbol symbol)
public System.Void BindMemberFromValue<TValue>(Expression<Func<TModel,TValue>> property, System.CommandLine.Symbol 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.CliArgument argument)
public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.CliOption option)
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.Threading.Tasks.Task<System.Int32> InvokeAsync(System.CommandLine.ParseResult parseResult, System.Threading.CancellationToken cancellationToken = null)
public class ModelDescriptor
public static ModelDescriptor FromType<T>()
Expand Down
Loading