wabbajack/Wabbajack.CLI/CommandLineBuilder.cs

28 lines
705 B
C#
Raw Normal View History

2021-09-27 12:42:46 +00:00
using System.Collections.Generic;
using System.CommandLine;
using System.Threading.Tasks;
using Wabbajack.CLI.Verbs;
using Wabbajack.Services.OSIntegrated;
2021-10-23 16:51:17 +00:00
namespace Wabbajack.CLI;
public class CommandLineBuilder
2021-09-27 12:42:46 +00:00
{
2021-10-23 16:51:17 +00:00
private readonly IConsole _console;
private readonly IEnumerable<IVerb> _verbs;
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
public CommandLineBuilder(IEnumerable<IVerb> verbs, IConsole console, LoggingRateLimiterReporter _)
{
_console = console;
_verbs = verbs;
}
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
public async Task<int> Run(string[] args)
{
var root = new RootCommand();
foreach (var verb in _verbs)
root.Add(verb.MakeCommand());
2022-01-18 22:58:54 +00:00
2021-10-23 16:51:17 +00:00
return await root.InvokeAsync(args);
2021-09-27 12:42:46 +00:00
}
}