Refactor (#56)

This commit is contained in:
Alexey Golub
2020-05-23 18:45:07 +03:00
committed by GitHub
parent 17449e0794
commit bed22b6500
38 changed files with 1624 additions and 1521 deletions

View File

@@ -0,0 +1,23 @@
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>());
}
}