summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-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;