[CLI] Cleanup

This commit is contained in:
Tyrrrz
2021-03-24 22:39:27 +02:00
parent 58464d8708
commit 1b8af364d3
2 changed files with 46 additions and 33 deletions

View File

@@ -1,4 +1,6 @@
using CliFx.Infrastructure;
using System;
using System.Threading.Tasks;
using CliFx.Infrastructure;
using Spectre.Console;
namespace DiscordChatExporter.Cli.Utils.Extensions
@@ -34,5 +36,22 @@ namespace DiscordChatExporter.Cli.Utils.Extensions
new ProgressBarColumn(),
new PercentageColumn()
});
public static async ValueTask StartTaskAsync(
this ProgressContext progressContext,
string description,
Func<ProgressTask, ValueTask> performOperationAsync)
{
var progressTask = progressContext.AddTask(description, new ProgressTaskSettings {MaxValue = 1});
try
{
await performOperationAsync(progressTask);
}
finally
{
progressTask.StopTask();
}
}
}
}