Files
cc-haxe/src/bin/KSettings.hx

69 lines
1.4 KiB
Haxe

package bin;
import kernel.KernelSettings;
import lib.CLIAppBase;
@:build(macros.Binstore.includeBin("Kernel settings", ["ksettings", "kset"]))
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;
});
}
}