Add CLI process and GUI start/stop commands with process management

This commit is contained in:
Stone_Red
2026-06-09 22:55:51 +02:00
parent f7eea21de5
commit a583a5ab44
4 changed files with 108 additions and 30 deletions
+12
View File
@@ -11,6 +11,18 @@ public class StartGuiCommand : ICommand
public void Execute(string? arguments, Action<string> printLine)
{
printLine("Starting Desktop Process...");
if (ProcessManager.IsProcessRunning<DesktopProcess>())
{
printLine("Desktop Process is already running.");
return;
}
foreach (Process process in ProcessManager.GetProcessesOfType<CliProcess>())
{
ProcessManager.StopProcess(process.Id);
}
_ = ProcessManager.SpawnProcess<DesktopProcess>();
}
}
+31
View File
@@ -0,0 +1,31 @@
using Cosmos.Kernel.System.Graphics;
using Org.BouncyCastle.Bcpg;
using RemSox.Processes;
using RemSox.Processing;
using RemSox.UI.GUI.Windows;
namespace RemSox.UI.CLI.Commands;
public class StopGuiCommand : ICommand
{
public string Name => "stop-gui";
public string Description => "Stops the Graphical User Interface (Desktop Process)";
public async void Execute(string? arguments, Action<string> printLine)
{
printLine("Stopping Desktop Process...");
if (!ProcessManager.IsProcessRunning<DesktopProcess>())
{
printLine("Desktop Process is not running.");
return;
}
foreach (Process process in ProcessManager.GetProcessesOfType<DesktopProcess>())
{
await ProcessManager.StopProcessAndWaitAsync(process.Id);
}
_ = ProcessManager.SpawnProcess<CliProcess>();
}
}