mirror of
https://github.com/Stone-Red-Code/RemSox.git
synced 2026-09-08 23:41:57 +02:00
Initial commit
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace RemSox.UI.GUI.CLI.Commands;
|
||||
|
||||
public sealed class ClearCommand : ICommand
|
||||
{
|
||||
public string Name => "clear";
|
||||
|
||||
public string Description => "Clear the screen";
|
||||
|
||||
public void Execute(string? arguments)
|
||||
{
|
||||
Console.Clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace RemSox.UI.GUI.CLI.Commands;
|
||||
|
||||
public sealed class HaltCommand : ICommand
|
||||
{
|
||||
public string Name => "halt";
|
||||
|
||||
public string Description => "Halt the system";
|
||||
|
||||
public void Execute(string? arguments)
|
||||
{
|
||||
Console.WriteLine("Halting system...");
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace RemSox.UI.GUI.CLI.Commands;
|
||||
|
||||
public sealed class HelpCommand : ICommand
|
||||
{
|
||||
public string Name => "help";
|
||||
|
||||
public string Description => "Show this help message";
|
||||
|
||||
public void Execute(string? arguments)
|
||||
{
|
||||
Console.WriteLine("Available commands:");
|
||||
|
||||
foreach (ICommand command in CommandManager.GetCommands())
|
||||
{
|
||||
Console.WriteLine($" {command.Name,-12} - {command.Description}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using RemSox.Processing;
|
||||
|
||||
namespace RemSox.UI.GUI.CLI.Commands;
|
||||
|
||||
public sealed class SpawnTestProcessCommand : ICommand
|
||||
{
|
||||
public string Name => "spawn test";
|
||||
|
||||
public string Description => "Spawn the test process";
|
||||
|
||||
public void Execute(string? arguments)
|
||||
{
|
||||
int processId = ProcessManager.SpawnProcess<TestProcess>();
|
||||
Console.WriteLine($"Spawned TestProcess with ID {processId}");
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ListProcessesCommand : ICommand
|
||||
{
|
||||
public string Name => "ps";
|
||||
|
||||
public string Description => "List running processes";
|
||||
|
||||
public void Execute(string? arguments)
|
||||
{
|
||||
IEnumerable<Process> processes = ProcessManager.GetAllProcesses();
|
||||
|
||||
Console.WriteLine("Running processes:");
|
||||
|
||||
foreach (Process process in processes)
|
||||
{
|
||||
Console.WriteLine($" ID: {process.Id}, Name: {process.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class StopProcessCommand : ICommand
|
||||
{
|
||||
public string Name => "stop";
|
||||
|
||||
public string Description => "Stop a process by ID";
|
||||
|
||||
public void Execute(string? arguments)
|
||||
{
|
||||
string? idText = arguments;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(idText))
|
||||
{
|
||||
Console.WriteLine("Usage: stop <process-id>");
|
||||
return;
|
||||
}
|
||||
|
||||
if (int.TryParse(idText, out int processId))
|
||||
{
|
||||
ProcessManager.StopProcess(processId);
|
||||
Console.WriteLine($"Stopped process with ID {processId}");
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine("Invalid process ID");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user