mirror of
https://github.com/nsnail/dot.git
synced 2025-06-17 21:13:21 +08:00
23 lines
571 B
C#
23 lines
571 B
C#
namespace Dot;
|
|
|
|
internal abstract class ToolBase<TOption> : Command<TOption> where TOption : OptionBase
|
|
{
|
|
protected TOption Opt { get; private set; }
|
|
protected abstract Task Core();
|
|
|
|
protected virtual async Task Run()
|
|
{
|
|
await Core();
|
|
if (Opt.KeepSession) {
|
|
AnsiConsole.MarkupLine(Str.PressAnyKey);
|
|
AnsiConsole.Console.Input.ReadKey(true);
|
|
}
|
|
}
|
|
|
|
public override int Execute(CommandContext context, TOption option)
|
|
{
|
|
Opt = option;
|
|
Run().Wait();
|
|
return 0;
|
|
}
|
|
} |