public static void printGlobalHelp() {
System.out.println(StringResources.NEW_LINE + "Usage: "
- + "em-cli [global options] <command> [command options]"); //$NON-NLS-1$
+ + "em-cli [global options] <COMMAND> [command options]"); //$NON-NLS-1$
// print global options
System.out.println("");
public static void printCommandHelp(Command action) {
String mandatoryOptions = "";
+ int count = 0;
for (Option c : action.getOptionList()) {
if (c.isMandatory()) {
mandatoryOptions += " " + c.getShortUsage();
+ } else {
+ count++;
}
}
- System.out.println("Usage: " + "em-cli " //$NON-NLS-1$ //$NON-NLS-2$
- + action.getCommand() + mandatoryOptions + " [options]"); //$NON-NLS-1$
+ String usage = "Usage: " + "em-cli " //$NON-NLS-1$ //$NON-NLS-2$
+ + action.getCommand() + mandatoryOptions;
+ if (count > 0) {
+ usage += " [options]"; //$NON-NLS-1$
+ }
+ System.out.println(usage);
System.out.println("");
System.out.println("Command description"); //$NON-NLS-1$
System.out.println();
System.out.println("Examples"); //$NON-NLS-1$
- printWithLine(action.getUsage());
+ printUsage(action.getUsage());
}
private static void printWithLine(String value) {
}
}
+ private static void printUsage(String value) {
+ assert value != null;
+
+ String[] usages = value.split(StringResources.NEW_LINE);
+ boolean odd = false;
+ for (String usage : usages) {
+ if (!odd) {
+ System.out.println(" " + usage);
+ odd = true;
+ } else {
+ System.out.println(" " + "em-cli " + usage);
+ odd = false;
+ }
+ }
+ }
+
private static int columns = 0;
public static void printKeyandValue(String key, String value) {
- printCommandDescription(key, value);
+ printCommandDescription(key, ": " + value);
}
private static void printOptionDescription(String value, String description) {