aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-09-11 18:39:55 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-09-11 18:40:41 +0530
commitee757a5761156fcbcff3d0bd4f6e75bb0931d536 (patch)
treedf596d0de0261e1c00a814b0922a8bc757adf50c /main/src
parent768078d72d2ddefd7db35f269584b6ca38cc5414 (diff)
CLI profile support
invoke CLI with --profile <name> to persist the settings across the sessions. CLI-5 Change-Id: I214334dab11fecdb730c780976d5d9bb2c14509d Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'main/src')
-rw-r--r--main/src/main/java/org/onap/cli/main/OnapCli.java29
-rw-r--r--main/src/main/java/org/onap/cli/main/conf/OnapCliConstants.java3
2 files changed, 29 insertions, 3 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 f689830a..71d9cf77 100644
--- a/main/src/main/java/org/onap/cli/main/OnapCli.java
+++ b/main/src/main/java/org/onap/cli/main/OnapCli.java
@@ -118,6 +118,25 @@ public class OnapCli {
}
}
+
+ /**
+ * Handles profile. --profile or -c
+ */
+ public void handleProfile() {
+ try {
+ if ((args.size() == 2) && (this.getLongOption(OnapCliConstants.PARAM_PROFILE_LONG).equals(args.get(0))
+ || this.getShortOption(OnapCliConstants.PARAM_PROFILE_SHORT).equals(args.get(0)))) {
+
+ OnapCommandRegistrar.getRegistrar().setProfile(args.get(1));
+ //Make space of interactive mode
+ this.args = new ArrayList<>();
+ }
+ } catch (Exception e) {
+ this.print(e);
+ this.exitFailure();
+ }
+ }
+
private String getDirectiveHelp() throws OnapCommandHelpFailed {
OnapCommandResult help = new OnapCommandResult();
help.setType(ResultType.TABLE);
@@ -345,13 +364,17 @@ public class OnapCli {
}
if (this.exitCode == -1) {
+ this.handleProfile();
+ }
+
+ if (this.exitCode == -1) {
this.handleInteractive();
}
- if (this.exitCode == -1) {
- this.handleCommand();
- }
+ if (this.exitCode == -1) {
+ this.handleCommand();
}
+ }
/**
* Main method.
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 2ce12f33..337cd41c 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
@@ -24,6 +24,9 @@ public final class OnapCliConstants {
public static final String PARAM_VERSION_SHORT = "v";
public static final String PARAM_VERSION_LONG = "version";
+ public static final String PARAM_PROFILE_SHORT = "c";
+ public static final String PARAM_PROFILE_LONG = "profile";
+
public static final int EXIT_SUCCESS = 0;
public static final int EXIT_FAILURE = 1;