Files
CliFx/CliFx.Tests/Internal/CommandHelper.cs
Alexey Golub bed22b6500 Refactor (#56)
2020-05-23 18:45:07 +03:00

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>());
}
}