36 lines
910 B
C#
36 lines
910 B
C#
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using Spectre.Console;
|
|
using Toak.Audio;
|
|
using Toak.Core;
|
|
using Toak.IO;
|
|
|
|
namespace Toak.Commands;
|
|
|
|
public static class DiscardCommand
|
|
{
|
|
public static async Task ExecuteAsync(bool pipeToStdout, bool verbose)
|
|
{
|
|
Logger.Verbose = verbose;
|
|
|
|
if (StateTracker.IsRecording())
|
|
{
|
|
AudioRecorder.StopRecording();
|
|
var wavPath = AudioRecorder.GetWavPath();
|
|
if (File.Exists(wavPath)) File.Delete(wavPath);
|
|
Notifications.Notify("Toak", "Recording discarded");
|
|
if (!pipeToStdout)
|
|
{
|
|
AnsiConsole.MarkupLine("[yellow]Recording discarded.[/]");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!pipeToStdout)
|
|
{
|
|
AnsiConsole.MarkupLine("[grey]No active recording to discard.[/]");
|
|
}
|
|
}
|
|
}
|
|
}
|