Commit 845a15a9 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

add better help text to utils command of vader-console

parent e2677bf3
Pipeline #177904 canceled with stages
in 27 minutes and 41 seconds
......@@ -26,7 +26,7 @@
are possible with a fixed height of 5m.
- vadere-console `utils` subCommand:
* A miscellaneous collector of simple function operating on a single scenario file.
* -f (input [required])
* -f (input file or directory depending on method m [required])
* -o (ouput file or directory depending on method m [optional])
* -m (name of method.) See subparser help for allowed functions.
* currently implementd:
......
......@@ -198,17 +198,17 @@ public class VadereConsole {
.help("Run utility functions.")
.setDefault("func", utilsSubCommand);
misc.addArgument("--scenario-file", "-f")
misc.addArgument("-i")
.required(true)
.type(String.class)
.dest("scenario-file")
.help("Scenario to work with.");
.dest("input")
.help("A input file or directory depending on called method.");
misc.addArgument("--output", "-o")
misc.addArgument( "-o")
.required(false)
.type(String.class)
.dest("output")
.help("A output file or folder depending on called method.");
.help("A output file or directory depending on called method.");
String[] utilMethods = utilsSubCommand.methodsString();
......@@ -217,7 +217,7 @@ public class VadereConsole {
.type(String.class)
.choices(utilMethods)
.dest("method")
.help("Method name to call.");
.help("Method name to call." + utilsSubCommand.methodHelp());
}
}
......@@ -3,6 +3,7 @@ package org.vadere.simulator.entrypoints.cmd.commands;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.commons.lang3.tuple.Pair;
import org.vadere.simulator.entrypoints.ScenarioFactory;
import org.vadere.simulator.entrypoints.cmd.SubCommandRunner;
import org.vadere.simulator.models.potential.fields.IPotentialField;
......@@ -28,13 +29,13 @@ public class UtilsSubCommand implements SubCommandRunner {
private final static Logger logger = Logger.getLogger(UtilsSubCommand.class);
private HashMap<String, SubCommandRunner> methods;
private HashMap<String, Pair<String, SubCommandRunner>> methods;
public UtilsSubCommand() {
methods = new HashMap<>();
methods.put("getHash", this::getHash);
methods.put("binCache", this::calculateBinCache);
methods.put("txtCache", this::calculateTextCache);
methods.put("getHash", Pair.of("[-i: file, -o: ignored]", this::getHash));
methods.put("binCache", Pair.of("[-i: file, -o: directory]",this::calculateBinCache));
methods.put("txtCache", Pair.of("[-i: file, -o: directory]",this::calculateTextCache));
}
......@@ -45,6 +46,12 @@ public class UtilsSubCommand implements SubCommandRunner {
return ret;
}
public String methodHelp(){
StringBuilder sb = new StringBuilder();
methods.forEach((key, value) -> sb.append("\n --> ").append(key).append(":").append(value.getLeft()));
return sb.toString();
}
private Scenario createScenario(String path) throws IOException {
Scenario scenario = null;
try {
......@@ -61,7 +68,7 @@ public class UtilsSubCommand implements SubCommandRunner {
public void run(Namespace ns, ArgumentParser parser) throws Exception {
String m = ns.get("method");
SubCommandRunner runner = methods.get(m);
SubCommandRunner runner = methods.get(m).getRight();
if (runner != null){
runner.run(ns, parser);
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment