Allow app activation by last component

Examples:
onos> app activate events
activate-ed org.onosproject.events

onos> app activate netconf
Did you mean one of: [org.onosproject.drivers.netconf, org.onosproject.netconf]

Change-Id: I6bdee9f5fed3b65c36f676bee4e97f6a77d37643
diff --git a/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java b/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java
index 5a12bf6..69e47d8 100644
--- a/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java
@@ -19,10 +19,13 @@
 import org.apache.karaf.shell.commands.Command;
 import org.onosproject.app.ApplicationAdminService;
 import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.core.Application;
 import org.onosproject.core.ApplicationId;
 
 import java.io.IOException;
 import java.net.URL;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * Manages application inventory.
@@ -83,6 +86,23 @@
     private boolean manageApp(ApplicationAdminService service, String name) {
         ApplicationId appId = service.getId(name);
         if (appId == null) {
+            List<Application> matches = service.getApplications().stream()
+                .filter(app -> app.id().name().matches(".*\\." + name + "$"))
+                .collect(Collectors.toList());
+
+            if (matches.size() == 1) {
+                // Found match
+                appId = matches.iterator().next().id();
+            } else if (!matches.isEmpty()) {
+                print("Did you mean one of: %s",
+                      matches.stream()
+                          .map(Application::id)
+                          .map(ApplicationId::name)
+                          .collect(Collectors.toList()));
+                return false;
+            }
+        }
+        if (appId == null) {
             print("No such application: %s", name);
             return false;
         }
@@ -97,6 +117,7 @@
             print("Unsupported command: %s", command);
             return false;
         }
+        print("%s-ed %s", command, appId.name());
         return true;
     }