added bin: lsps

This commit is contained in:
Djeeberjr 2023-05-23 14:51:56 +02:00
parent e73b4c4d14
commit c4260aa719
3 changed files with 28 additions and 1 deletions

21
src/bin/LSPS.hx Normal file
View File

@ -0,0 +1,21 @@
package bin;
import kernel.ps.ProcessManager;
import kernel.ps.ProcessHandle;
import kernel.ps.Process;
class LSPS implements Process {
public function new() {}
public function run(handle:ProcessHandle) {
var pids = ProcessManager.listProcesses();
handle.writeLine('Count: ${pids.length}');
for (pid in pids) {
handle.writeLine('${pid}');
}
handle.close();
}
}

View File

@ -1,5 +1,6 @@
package kernel.binstore; package kernel.binstore;
import bin.LSPS;
import bin.Turtle; import bin.Turtle;
import bin.Terminal; import bin.Terminal;
import haxe.ds.ReadOnlyArray; import haxe.ds.ReadOnlyArray;
@ -21,7 +22,8 @@ class BinStore {
{c: Net, name: "Net", aliases: ["net"]}, {c: Net, name: "Net", aliases: ["net"]},
{c: Redstone, name: "Redstone", aliases: ["redstone","rs"]}, {c: Redstone, name: "Redstone", aliases: ["redstone","rs"]},
{c: Terminal, name: "Terminal", aliases: ["terminal","term"]}, {c: Terminal, name: "Terminal", aliases: ["terminal","term"]},
{c: Turtle, name: "Turtle", aliases: ["turtle"]} {c: Turtle, name: "Turtle", aliases: ["turtle"]},
{c: LSPS, name: "PM", aliases: ["lsps"]}
]; ];
@:allow(kernel.Init) @:allow(kernel.Init)

View File

@ -34,4 +34,8 @@ class ProcessManager {
private static function removeProcess(pid:PID):Void { private static function removeProcess(pid:PID):Void {
processList.remove(pid); processList.remove(pid);
} }
public static function listProcesses():Array<PID> {
return [for (pid in processList.keys()) pid];
}
} }