added kernel settings
This commit is contained in:
67
src/bin/KSettings.hx
Normal file
67
src/bin/KSettings.hx
Normal file
@@ -0,0 +1,67 @@
|
||||
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;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user