mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
23 lines
755 B
C#
23 lines
755 B
C#
using System.Collections.Generic;
|
|
using CliFx.Domain;
|
|
|
|
namespace CliFx.Tests.Internal
|
|
{
|
|
internal static class CommandHelper
|
|
{
|
|
public static TCommand ResolveCommand<TCommand>(CommandInput input, IReadOnlyDictionary<string, string> environmentVariables)
|
|
where TCommand : ICommand, new()
|
|
{
|
|
var schema = CommandSchema.TryResolve(typeof(TCommand))!;
|
|
|
|
var instance = new TCommand();
|
|
schema.Bind(instance, input, environmentVariables);
|
|
|
|
return instance;
|
|
}
|
|
|
|
public static TCommand ResolveCommand<TCommand>(CommandInput input)
|
|
where TCommand : ICommand, new() =>
|
|
ResolveCommand<TCommand>(input, new Dictionary<string, string>());
|
|
}
|
|
} |