Added support for -s|--short option when listing apps.
Added support for -s|--short option when listing configs.

Change-Id: I9235cc5eec34826ff90feb5642981080fcfa1524
diff --git a/cli/src/main/java/org/onosproject/cli/app/ApplicationsListCommand.java b/cli/src/main/java/org/onosproject/cli/app/ApplicationsListCommand.java
index d9debdb..5766c57 100644
--- a/cli/src/main/java/org/onosproject/cli/app/ApplicationsListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/app/ApplicationsListCommand.java
@@ -42,6 +42,13 @@
             "%s id=%d, name=%s, version=%s, origin=%s, description=%s, " +
                     "features=%s, featuresRepo=%s, permissions=%s";
 
+    private static final String SHORT_FMT =
+            "%s %3d  %-28s  %-8s  %-16s  %s";
+
+    @Option(name = "-s", aliases = "--short", description = "Show short output only",
+            required = false, multiValued = false)
+    private boolean shortOnly = false;
+
     @Option(name = "-a", aliases = "--active", description = "Show active only",
             required = false, multiValued = false)
     private boolean activeOnly = false;
@@ -59,11 +66,17 @@
             for (Application app : apps) {
                 boolean isActive = service.getState(app.id()) == ACTIVE;
                 if (activeOnly && isActive || !activeOnly) {
-                    print(FMT, isActive ? "*" : " ",
-                          app.id().id(), app.id().name(), app.version(), app.origin(),
-                          app.description(), app.features(),
-                          app.featuresRepo().isPresent() ? app.featuresRepo().get().toString() : "",
-                          app.permissions());
+                    if (shortOnly) {
+                        print(SHORT_FMT, isActive ? "*" : " ",
+                              app.id().id(), app.id().name(), app.version(),
+                              app.origin(), app.description());
+                    } else {
+                        print(FMT, isActive ? "*" : " ",
+                              app.id().id(), app.id().name(), app.version(), app.origin(),
+                              app.description(), app.features(),
+                              app.featuresRepo().isPresent() ? app.featuresRepo().get().toString() : "",
+                              app.permissions());
+                    }
                 }
             }
         }
diff --git a/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommand.java b/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommand.java
index 910f7b1..de73c91 100644
--- a/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommand.java
@@ -17,10 +17,12 @@
 
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
 import org.onosproject.cfg.ComponentConfigService;
 import org.onosproject.cfg.ConfigProperty;
 import org.onosproject.cli.AbstractShellCommand;
 
+import java.util.Optional;
 import java.util.Set;
 
 import static com.google.common.base.Strings.isNullOrEmpty;
@@ -36,6 +38,12 @@
     static final String SET = "set";
 
     private static final String FMT = "    name=%s, type=%s, value=%s, defaultValue=%s, description=%s";
+    private static final String SHORT_FMT = "    %s=%s";
+
+    @Option(name = "-s", aliases = "--short", description = "Show short output only",
+            required = false, multiValued = false)
+    private boolean shortOnly = false;
+
 
     @Argument(index = 0, name = "command",
             description = "Command name (activate|deactivate|uninstall)",
@@ -87,12 +95,29 @@
     private void listComponentProperties(String component) {
         Set<ConfigProperty> props = service.getProperties(component);
         print("%s", component);
-        props.forEach(p -> print(FMT, p.name(), p.type().toString().toLowerCase(),
-                                 p.value(), p.defaultValue(), p.description()));
+        if (shortOnly) {
+            props.forEach(p -> print(SHORT_FMT, p.name(), p.value()));
+        } else {
+            props.forEach(p -> print(FMT, p.name(), p.type().toString().toLowerCase(),
+                                     p.value(), p.defaultValue(), p.description()));
+        }
     }
 
     private void listComponentProperty(String component, String name) {
-        // FIXME: implement after getProperty is defined and implemented
+        Set<ConfigProperty> props = service.getProperties(component);
+        Optional<ConfigProperty> property = props.stream()
+                .filter(p -> p.name().equals(name)).findFirst();
+        if (!property.isPresent()) {
+            System.err.println("Property " + name + " for component " + component + " not found");
+            return;
+        }
+        ConfigProperty p = property.get();
+        if (shortOnly) {
+            print(SHORT_FMT, p.name(), p.value());
+        } else {
+            print(FMT, p.name(), p.type().toString().toLowerCase(), p.value(),
+                  p.defaultValue(), p.description());
+        }
     }
 
 }