summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/pom.xml5
-rw-r--r--main/src/main/java/org/onap/cli/main/OnapCli.java19
2 files changed, 24 insertions, 0 deletions
diff --git a/main/pom.xml b/main/pom.xml
index 451c55df..43a7000d 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -32,6 +32,11 @@
<packaging>jar</packaging>
<dependencies>
<dependency>
+ <groupId>org.onap.cli</groupId>
+ <artifactId>cli-sample-yaml-generator</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
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 35df0e37..0ed27ea1 100644
--- a/main/src/main/java/org/onap/cli/main/OnapCli.java
+++ b/main/src/main/java/org/onap/cli/main/OnapCli.java
@@ -25,8 +25,10 @@ import org.apache.commons.io.IOUtils;
import org.onap.cli.fw.OnapCommand;
import org.onap.cli.fw.OnapCommandRegistrar;
import org.onap.cli.fw.conf.Constants;
+import org.onap.cli.fw.conf.OnapCommandConfg;
import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandHelpFailed;
+import org.onap.cli.fw.error.OnapCommandInvalidSample;
import org.onap.cli.fw.error.OnapCommandWarning;
import org.onap.cli.fw.input.OnapCommandParameter;
import org.onap.cli.fw.output.OnapCommandResult;
@@ -37,6 +39,7 @@ import org.onap.cli.fw.output.ResultType;
import org.onap.cli.main.conf.OnapCliConstants;
import org.onap.cli.main.interactive.StringCompleter;
import org.onap.cli.main.utils.OnapCliUtils;
+import org.onap.cli.sample.yaml.SampleYamlGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -355,9 +358,12 @@ public class OnapCli {
OnapCliUtils.populateParams(cmd.getParameters(), args);
OnapCommandResult result = cmd.execute();
+
this.print(result.getDebugInfo());
this.print(result.print());
this.exitSuccessfully();
+
+ generateSmapleYaml(result);
} catch (Exception e) {
this.print(cmd.getResult().getDebugInfo());
if (e instanceof OnapCommandWarning) {
@@ -370,6 +376,19 @@ public class OnapCli {
}
}
+ private void generateSmapleYaml(OnapCommandResult result) throws OnapCommandException {
+ if (OnapCommandConfg.isSampleGenerateEnabled() && this.getExitCode() == OnapCliConstants.EXIT_SUCCESS) {
+ try {
+ SampleYamlGenerator.generateSampleYaml(args, result.print(),
+ OnapCommandRegistrar.getRegistrar().getEnabledProductVersion(),
+ OnapCommandConfg.getSampleGenerateTargetFolder(),
+ result.isDebug());
+ } catch (IOException error) {
+ throw new OnapCommandInvalidSample(args.get(0), error);
+ }
+ }
+ }
+
/**
* Handles all client input.
*/