feat: Introduce explicit start, stop, and status commands, including minimum recording duration.
This commit is contained in:
32
Commands/StartCommand.cs
Normal file
32
Commands/StartCommand.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading.Tasks;
|
||||
using Spectre.Console;
|
||||
using Toak.Core;
|
||||
|
||||
namespace Toak.Commands;
|
||||
|
||||
public static class StartCommand
|
||||
{
|
||||
public static async Task ExecuteAsync(bool verbose)
|
||||
{
|
||||
Logger.Verbose = verbose;
|
||||
var socketPath = DaemonService.GetSocketPath();
|
||||
try
|
||||
{
|
||||
using var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified);
|
||||
var endPoint = new UnixDomainSocketEndPoint(socketPath);
|
||||
await socket.ConnectAsync(endPoint);
|
||||
await socket.SendAsync(new byte[] { 1 }, SocketFlags.None);
|
||||
if (verbose) Console.WriteLine("Sent START command to daemon.");
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
AnsiConsole.MarkupLine("[red]Failed to connect to Toak daemon.[/]");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AnsiConsole.MarkupLine($"[red]Error:[/] {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user