Refactor process spawning command and move TestProcess to its own file

This commit is contained in:
Stone_Red
2026-06-10 03:22:27 +02:00
parent a1dc9f4c5e
commit f6e03c052e
5 changed files with 78 additions and 50 deletions
+22 -5
View File
@@ -1,17 +1,34 @@
using RemSox.Processes;
using RemSox.Processing;
namespace RemSox.UI.CLI.Commands;
public sealed class SpawnTestProcessCommand : ICommand
public sealed class SpawnProcessCommand : ICommand
{
public string Name => "spawn test";
public string Name => "spawn";
public string Description => "Spawn the test process";
public string Description => "Spawn a new process";
public void Execute(string? arguments, Action<string> printLine)
{
int processId = ProcessManager.SpawnProcess<TestProcess>();
printLine($"Spawned TestProcess with ID {processId}");
arguments = arguments?.Trim();
int? processId = arguments switch
{
"test" => ProcessManager.SpawnProcess<TestProcess>(),
"terminal" => ProcessManager.SpawnProcess<TerminalProcess>(),
_ => null
};
if (processId is not null)
{
printLine($"Spawned process with ID {processId}");
}
else
{
printLine("Usage: spawn <process-name>");
printLine("Available processes: test, terminal");
}
}
}
+2 -2
View File
@@ -27,10 +27,10 @@ public sealed class Window(string title, int processId, int id, IRenderSource re
public bool AutoFlush { get; set; } = false;
/// <summary> Event raised when a keyboard event is handled by this window. </summary>
public event Action<Cosmos.Kernel.System.Keyboard.KeyEvent>? OnKeyEvent;
public event Action<Sys.Keyboard.KeyEvent>? OnKeyEvent;
/// <summary> Dispatches a key event to the window's registered event handlers. </summary>
public void HandleKeyEvent(Cosmos.Kernel.System.Keyboard.KeyEvent keyEvent)
public void HandleKeyEvent(Sys.Keyboard.KeyEvent keyEvent)
{
OnKeyEvent?.Invoke(keyEvent);
}