dot/src/backend/Dot/ToolBase.cs
2023-12-13 18:43:53 +08:00

25 lines
679 B
C#

namespace Dot;
internal abstract class ToolBase<TOption> : Command<TOption>
where TOption : OptionBase
{
protected TOption Opt { get; private set; }
public override int Execute(CommandContext context, TOption settings)
{
Opt = settings;
RunAsync().ConfigureAwait(false).GetAwaiter().GetResult();
return 0;
}
protected abstract Task CoreAsync();
protected virtual async Task RunAsync()
{
await CoreAsync().ConfigureAwait(false);
if (Opt.) {
AnsiConsole.MarkupLine(Ln.);
_ = AnsiConsole.Console.Input.ReadKey(true);
}
}
}