diff options
Diffstat (limited to 'main/src')
4 files changed, 17 insertions, 39 deletions
diff --git a/main/src/main/java/org/onap/cli/main/OnapCli.java b/main/src/main/java/org/onap/cli/main/OnapCli.java index 528c3e18..ac63fdfa 100644 --- a/main/src/main/java/org/onap/cli/main/OnapCli.java +++ b/main/src/main/java/org/onap/cli/main/OnapCli.java @@ -82,11 +82,9 @@ public class OnapCli { */ public void handleHelp() { try { - // By default, it prints help - if ((args.isEmpty()) - || ((args.size() == 1) && (this.getLongOption(OnapCliConstants.PARAM_HELP_LOGN).equals(args.get(0)) - || this.getShortOption(OnapCliConstants.PARAM_HELP_SHORT).equals(args.get(0))))) { - this.print(IOUtils.toString(this.getClass().getClassLoader().getResourceAsStream("README.md"))); + if ((args.size() == 1) && (this.getLongOption(OnapCliConstants.PARAM_HELP_LOGN).equals(args.get(0)) + || this.getShortOption(OnapCliConstants.PARAM_HELP_SHORT).equals(args.get(0)))) { + this.print(IOUtils.toString(this.getClass().getClassLoader().getResourceAsStream("onap-readme.txt"))); String help = OnapCommandRegistrar.getRegistrar().getHelp(); this.print(help); this.exitSuccessfully(); @@ -115,11 +113,10 @@ public class OnapCli { } /** - * Handles Interactive Mode. --interactive or -i + * Handles Interactive Mode. */ public void handleInteractive() { // NOSONAR - if (isInteractive()) { - + if (args.isEmpty()) { ConsoleReader console = null; try { OnapCommandRegistrar.getRegistrar().setInteractiveMode(true); @@ -148,10 +145,15 @@ public class OnapCli { this.print(e); } } - - continue; + } else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_HELP)) { + try { + this.print(OnapCommandRegistrar.getRegistrar().getHelpForEnabledProductVersion()); + } catch (OnapCommandException e) { + this.print(e); + } + } else { + handleCommand(); } - handleCommand(); } } catch (IOException e) { // NOSONAR this.print("Failed to read console, " + e.getMessage()); @@ -172,20 +174,6 @@ public class OnapCli { } /** - * Checks if the command is interactive. - * - * @return boolean - */ - public boolean isInteractive() { - if ((args.size() == 1) && (this.getLongOption(OnapCliConstants.PARAM_INTERACTIVE_LONG).equals(args.get(0)) - || this.getShortOption(OnapCliConstants.PARAM_INTERACTIVE_SHORT).equals(args.get(0)))) { - return true; - } - - return false; - } - - /** * Creates console reader object. * * @return ConsoleReader @@ -198,7 +186,8 @@ public class OnapCli { StringCompleter strCompleter = new StringCompleter(OnapCommandRegistrar.getRegistrar().listCommandsForEnabledProductVersion()); strCompleter.add(OnapCliConstants.PARAM_INTERACTIVE_EXIT, OnapCliConstants.PARAM_INTERACTIVE_CLEAR, - OnapCliConstants.PARAM_INTERACTIVE_USE); + OnapCliConstants.PARAM_INTERACTIVE_USE, + OnapCliConstants.PARAM_INTERACTIVE_HELP); console.addCompleter(strCompleter); console.setPrompt(OnapCliConstants.PARAM_INTERACTIVE_PROMPT); } catch (OnapCommandException e) { // NOSONAR diff --git a/main/src/main/java/org/onap/cli/main/conf/OnapCliConstants.java b/main/src/main/java/org/onap/cli/main/conf/OnapCliConstants.java index 4db26f74..d01aa1e5 100644 --- a/main/src/main/java/org/onap/cli/main/conf/OnapCliConstants.java +++ b/main/src/main/java/org/onap/cli/main/conf/OnapCliConstants.java @@ -27,13 +27,12 @@ public final class OnapCliConstants { public static final int EXIT_SUCCESS = 0; public static final int EXIT_FAILURE = 1; - public static final String PARAM_INTERACTIVE_SHORT = "i"; - public static final String PARAM_INTERACTIVE_LONG = "interactive"; public static final String PARAM_INTERACTIVE_PROMPT = "onap>"; public static final String PARAM_INTERACTIVE_EXIT = "exit"; public static final String PARAM_INTERACTIVE_BYE = "bye"; public static final String PARAM_INTERACTIVE_CLEAR = "clear"; public static final String PARAM_INTERACTIVE_USE = "use"; + public static final String PARAM_INTERACTIVE_HELP = "help"; public static final String PARAM_INTERACTIVE_ARG_SPLIT_PATTERN = "\\s+"; private OnapCliConstants(){} diff --git a/main/src/main/resources/onap-readme.txt b/main/src/main/resources/onap-readme.txt index 1008737b..1784a348 100644 --- a/main/src/main/resources/onap-readme.txt +++ b/main/src/main/resources/onap-readme.txt @@ -13,6 +13,3 @@ To know the CLI usage, type onap [-h|--help] To know the usage of sub commands, type onap <command> [-h|--help] To know more, please refer the Onap wiki https://wiki.onap.org - -NOTE: This file has been deprecated in amesterdam release and is -replaced by README.md file
\ No newline at end of file diff --git a/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java b/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java index ff4b4362..a94252ee 100644 --- a/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java +++ b/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java @@ -126,14 +126,7 @@ public class OnapCliMainTest { @Test public void interactiveTest() { - cli = new OnapCli(new String[] { "-i" }); - boolean isInter = cli.isInteractive(); - - assertTrue(isInter); - cli = new OnapCli(new String[] { "--interactive" }); - isInter = cli.isInteractive(); - assertTrue(isInter); - cli.getExitCode(); + cli = new OnapCli(new String[] {}); mockConsole("exit"); cli.handleInteractive(); |