Added start of infra to runner.d

This commit is contained in:
Andrew Lalis 2023-03-24 09:01:10 +01:00
parent ae3c22422c
commit ed6db6298d
1 changed files with 49 additions and 4 deletions

53
runner.d Normal file → Executable file
View File

@ -11,12 +11,57 @@ import std.process;
import std.stdio;
import std.string;
import std.uni;
import core.thread;
int main() {
bool running = true;
writeln("Gymboard CLI: Type \"help\" for more information. Type \"exit\" to exit the CLI.");
while (running) {
string[] commandAndArgs = readln().strip.split!isWhite;
if (commandAndArgs.length == 0) continue;
string command = commandAndArgs[0].toLower();
if (command == "help") {
showHelp();
} else if (command == "exit") {
running = false;
} else if (command in commands) {
commands[command](commandAndArgs.length > 1 ? commandAndArgs[1 .. $] : []);
} else {
writefln!"Unknown command \"%s\"."(command);
}
}
writeln("Goodbye!");
return 0;
}
alias CommandFunction = void function(string[] args);
int main() {
while (true) {
string[] command = readln().split!isWhite;
CommandFunction[string] commands;
void registerCommand(string name, CommandFunction func) {
commands[name] = func;
}
void showHelp() {
writeln(q"HELP
Gymboard CLI: A tool for streamlining development.
Commands:
help Shows this message.
exit Exits the CLI, stopping any running services.
HELP");
}
class ProcessRunner : Thread {
private Pid processId;
public this(ProcessPipes pipes) {
super(&this.run);
this.processId = pipes.pid();
}
private void run() {
}
}
}