com.xlrit.gears.runner.driver.LoadConfig Maven / Gradle / Ivy
The newest version!
package com.xlrit.gears.runner.driver;
import java.util.Iterator;
import com.fasterxml.jackson.databind.JsonNode;
import com.xlrit.gears.base.util.DisplayedHelper;
import static com.xlrit.gears.runner.utils.CommandLineUtils.setString;
public class LoadConfig extends Config {
public String dataDir = "data";
public boolean initAuditing = false;
@Override
protected void readArg(String arg, Iterator args) {
switch (arg) {
case "--data-dir" -> setString(args, "DataDir", value -> dataDir = value);
case "--base-url" -> setString(args, "BaseUrl", value -> baseUrl = value);
case "--init-audit" -> initAuditing = true;
case "--dry-run" -> dryRun = true;
case "--debug" -> debug = true;
default -> super.readArg(arg, args);
}
}
@Override
public void readJson(JsonNode configNode) {
super.readJson(configNode);
JsonNode options = configNode.get("runnerOptions");
if (options != null) {
initAuditing = orElseBool(options.get("initAuditing"), initAuditing);
}
JsonNode dirs = configNode.get("dirs");
if (dirs != null) {
dataDir = orElseString(dirs.get("data"), dataDir);
}
}
@Override
protected DisplayedHelper getDisplayedHelper() {
return super.getDisplayedHelper()
.add("dataDir", dataDir)
.add("initAuditing", initAuditing);
}
}