Skip to content
Snippets Groups Projects
Commit ea8ce19c authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

Improving help formatting

parent b43604e1
No related branches found
No related tags found
No related merge requests found
......@@ -120,7 +120,7 @@ public class Action extends Command {
private final static String AVATAR_MUTATION = "avatar-mutation";
private final static String AVATAR_MUTATION_BATCH = "avatar-mutation-batch";
private final static String AVATAR_DRAW = "avatar-draw";
private final static String AVATAR_DRAW = "avatar-print";
private final static String AVATAR_PRINT = "avatar-draw";
private final static String AVATAR_RG_GENERATION = "avatar-rg";
private final static String AVATAR_UPPAAL_VALIDATE = "avatar-rg-validate";
......@@ -357,8 +357,11 @@ public class Action extends Command {
}
public String getDescription() {
return "Get the name of the model under edition TTool. If a variable is provided as argument, the " +
"result is saved into this variable";
return "Get the name of the model under edition TTool";
}
public String getUsage() {
return "If a variable is provided as argument, the result is saved into this variable";
}
public String executeCommand(String command, Interpreter interpreter) {
......@@ -708,8 +711,11 @@ public class Action extends Command {
}
public String getDescription() {
return "Generate the XML of a diplodocus model.\n<variable name>: variable in which the " +
"XML specification is saved";
return "Generate the XML of a diplodocus model";
}
public String getUsage() {
return "<variable name>: variable in which the XML specification is saved";
}
public String executeCommand(String command, Interpreter interpreter) {
......@@ -1123,9 +1129,6 @@ public class Action extends Command {
return "\n";
}
public String getExample() {
return "ap";
}
public String executeCommand(String command, Interpreter interpreter) {
......@@ -1163,9 +1166,6 @@ public class Action extends Command {
return "\n";
}
public String getExample() {
return "ad";
}
public String executeCommand(String command, Interpreter interpreter) {
......
......@@ -118,24 +118,24 @@ public class Command implements CommandInterface {
}
public String getHelp(int level) {
public String getHelp(int level, boolean printUsage) {
String dec = getLevelString(level);
/*String h = "";
h+= getCommand() + " (" + getShortCommand() + "): " + getUsage() + "\n" + getDescription() + "\n";
for (Command c: subcommands) {
h+= "\t" + c.getHelp();
}*/
StringBuffer b = new StringBuffer(dec + "* " + getCommand() + " (" + getShortCommand() + "): " + getUsage() + "\n" + dec + " " +
getDescription() +
"\n");
if (getExample().length() > 0) {
b.append(dec + "Example: " + getExample() + "\n");
StringBuffer b = new StringBuffer("\n" + dec + "* " + getCommand() + " (" + getShortCommand() + ")");
b.append(": " + getDescription());
if (printUsage) {
b.append("\n " + dec + getUsage());
if (getExample().length() > 0) {
b.append("\n" + dec + "Example: " + getExample());
}
} else {
if ((getUsage().length() + getExample().length()) > 0 ) {
b.append( " ...");
}
}
subcommands.forEach( (c) -> { b.append(c.getHelp(level + 1)); });
subcommands.forEach( (c) -> { b.append(c.getHelp(level + 1, false)); });
return b.toString();
}
......
......@@ -93,8 +93,8 @@ public class Help extends Command {
if (command.trim().length() == 0) {
String s = "";
for(Command c: Interpreter.commands) {
//s += c.getShortCommand() + "\t" + c.getCommand() + "\t" + c.getDescription() + "\n";
s += c.getShortCommand() + "\t" + c.getCommand() + "\n";
s += c.getShortCommand() + "\t" + c.getCommand() + "\t" + c.getDescription() + "\n";
//s += c.getShortCommand() + "\t" + c.getCommand() + "\n";
}
interpreter.print(s);
TraceManager.addDev("Info on command");
......@@ -108,7 +108,7 @@ public class Help extends Command {
return Interpreter.BAD_COMMAND_NAME;
}
interpreter.print(c.getHelp(1));
interpreter.print(c.getHelp(1, true));
return null;
......
......@@ -323,7 +323,7 @@ public class Interpreter implements Runnable, TerminalProviderInterface {
public String getHelp() {
StringBuffer buf = new StringBuffer("");
for (Command c : commands) {
buf.append(c.getHelp(0) + "\n");
buf.append(c.getHelp(0, true) + "\n");
}
return buf.toString();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment