cc-haxe/src/bin/KSettings.hx
2023-06-07 21:29:10 +02:00

67 lines
1.8 KiB
Haxe

package bin;
import kernel.KernelSettings;
import lib.CLIAppBase;
class KSettings extends CLIAppBase {
public function new() {
registerSyncSubcommand("get", (args)->{
var key = args[0];
if (key == null) {
handle.writeLine("Key not specified");
return false;
}
var value = switch (key){
case "hostname":
KernelSettings.hostname;
case "sitecontroller":
Std.string(KernelSettings.siteController);
default:
null;
}
if (value == null) {
handle.writeLine("Key not found or not set");
return false;
}
handle.writeLine(value);
return true;
}," <key>");
registerSyncSubcommand("set", (args)->{
var key = args[0];
if (key == null) {
handle.writeLine("Key not specified");
return false;
}
var value = args[1];
if (value == null) {
handle.writeLine("Value not specified");
return false;
}
switch (key){
case "hostname":
KernelSettings.hostname = value;
case "sitecontroller":
KernelSettings.siteController = Std.parseInt(value);
default:
handle.writeLine("Key not found");
return false;
}
return true;
}," <key> <value>");
registerSyncSubcommand("list", (args)->{
handle.writeLine("hostname");
handle.writeLine("sitecontroller");
return true;
});
}
}