From be10a98d70787bf7ad745f7876ab90d4b12158e4 Mon Sep 17 00:00:00 2001 From: "jihye424.kim" Date: Wed, 23 Mar 2016 17:23:10 +0900 Subject: [PATCH] CLI: modify format of usage - old-> : - new-> Change-Id: If155f5541faef96ecb199fed7bdaf1f0b158b769 Signed-off-by: jihye424.kim --- .../emulator/manager/console/util/OutputUtil.java | 33 ++++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/org/tizen/emulator/manager/console/util/OutputUtil.java b/src/org/tizen/emulator/manager/console/util/OutputUtil.java index 192ff85..c4aaa23 100644 --- a/src/org/tizen/emulator/manager/console/util/OutputUtil.java +++ b/src/org/tizen/emulator/manager/console/util/OutputUtil.java @@ -86,7 +86,7 @@ public class OutputUtil { public static void printGlobalHelp() { System.out.println(StringResources.NEW_LINE + "Usage: " - + "em-cli [global options] [command options]"); //$NON-NLS-1$ + + "em-cli [global options] [command options]"); //$NON-NLS-1$ // print global options System.out.println(""); @@ -105,14 +105,21 @@ public class OutputUtil { 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$ @@ -132,7 +139,7 @@ public class OutputUtil { System.out.println(); System.out.println("Examples"); //$NON-NLS-1$ - printWithLine(action.getUsage()); + printUsage(action.getUsage()); } private static void printWithLine(String value) { @@ -144,9 +151,25 @@ public class OutputUtil { } } + 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) { -- 2.7.4