Adding JSON format to the CLI. Intents and flows still need to be done.
diff --git a/cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java b/cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java
index 184a7e6..839d2841 100644
--- a/cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java
@@ -1,5 +1,6 @@
package org.onlab.onos.cli;
+import org.apache.karaf.shell.commands.Option;
import org.apache.karaf.shell.console.OsgiCommandSupport;
import org.onlab.osgi.DefaultServiceDirectory;
import org.onlab.osgi.ServiceNotFoundException;
@@ -9,6 +10,10 @@
*/
public abstract class AbstractShellCommand extends OsgiCommandSupport {
+ @Option(name = "-j", aliases = "--json", description = "Output JSON",
+ required = false, multiValued = false)
+ private boolean json = false;
+
/**
* Returns the reference to the implementation of the specified service.
*
@@ -46,6 +51,15 @@
*/
protected abstract void execute();
+ /**
+ * Indicates whether JSON format should be output.
+ *
+ * @return true if JSON is requested
+ */
+ protected boolean outputJson() {
+ return json;
+ }
+
@Override
protected Object doExecute() throws Exception {
try {