summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/main/java/org/onap/cli/main/OnapCli.java34
1 files changed, 17 insertions, 17 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 65edfc13..62b78fd5 100644
--- a/main/src/main/java/org/onap/cli/main/OnapCli.java
+++ b/main/src/main/java/org/onap/cli/main/OnapCli.java
@@ -303,24 +303,24 @@ public class OnapCli {
* exception
*/
private ConsoleReader createConsoleReader() throws IOException {
- ConsoleReader console = new ConsoleReader();
- try {
- StringCompleter strCompleter = new StringCompleter(OnapCommandRegistrar.getRegistrar().listCommandsForEnabledProductVersion());
- strCompleter.add(OnapCliConstants.PARAM_INTERACTIVE_EXIT,
- OnapCliConstants.PARAM_INTERACTIVE_CLEAR,
- OnapCliConstants.PARAM_INTERACTIVE_USE,
- OnapCliConstants.PARAM_INTERACTIVE_HELP,
- OnapCliConstants.PARAM_INTERACTIVE_VERSION,
- OnapCliConstants.PARAM_INTERACTIVE_SET,
- OnapCliConstants.PARAM_INTERACTIVE_UNSET,
- OnapCliConstants.PARAM_INTERACTIVE_PROFILE);
- console.addCompleter(strCompleter);
- console.setPrompt(OnapCliConstants.PARAM_INTERACTIVE_PROMPT + ":" + OnapCommandRegistrar.getRegistrar().getEnabledProductVersion() + ">");
- } catch (OnapCommandException e) { // NOSONAR
- this.print("Failed to load oclip commands," + e.getMessage());
+ try(ConsoleReader console = new ConsoleReader()){
+ try {
+ StringCompleter strCompleter = new StringCompleter(OnapCommandRegistrar.getRegistrar().listCommandsForEnabledProductVersion());
+ strCompleter.add(OnapCliConstants.PARAM_INTERACTIVE_EXIT,
+ OnapCliConstants.PARAM_INTERACTIVE_CLEAR,
+ OnapCliConstants.PARAM_INTERACTIVE_USE,
+ OnapCliConstants.PARAM_INTERACTIVE_HELP,
+ OnapCliConstants.PARAM_INTERACTIVE_VERSION,
+ OnapCliConstants.PARAM_INTERACTIVE_SET,
+ OnapCliConstants.PARAM_INTERACTIVE_UNSET,
+ OnapCliConstants.PARAM_INTERACTIVE_PROFILE);
+ console.addCompleter(strCompleter);
+ console.setPrompt(OnapCliConstants.PARAM_INTERACTIVE_PROMPT + ":" + OnapCommandRegistrar.getRegistrar().getEnabledProductVersion() + ">");
+ } catch (OnapCommandException e) { // NOSONAR
+ this.print("Failed to load oclip commands," + e.getMessage());
+ }
+ return console;
}
-
- return console;
}
/**