initial commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using System.CommandLine;
|
||||
using Hush.Daemon;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Hush.Cli.Commands;
|
||||
|
||||
public static class StopCommand
|
||||
{
|
||||
public static Command Create()
|
||||
{
|
||||
var command = new Command("stop", "Stop recording and process");
|
||||
command.SetHandler(async (context) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await using var client = new SocketClient();
|
||||
await client.ConnectAsync(TimeSpan.FromSeconds(2));
|
||||
await client.SendCommandAsync(DaemonProtocol.STOP);
|
||||
AnsiConsole.MarkupLine("[green]Stop command sent[/]");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AnsiConsole.MarkupLine($"[red]Error: {ex.Message}[/]");
|
||||
context.ExitCode = 1;
|
||||
}
|
||||
});
|
||||
return command;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user