Additional Implementation of installApp to CLI interface
Change-Id: Iea7ed2f4be5ffd9acc7e682d6f1625a9af53f902
diff --git a/cli/src/main/java/org/onosproject/cli/app/ApplicationNameCompleter.java b/cli/src/main/java/org/onosproject/cli/app/ApplicationNameCompleter.java
index 2d0a6f7..03409d0 100644
--- a/cli/src/main/java/org/onosproject/cli/app/ApplicationNameCompleter.java
+++ b/cli/src/main/java/org/onosproject/cli/app/ApplicationNameCompleter.java
@@ -54,30 +54,24 @@
// Command name is the second argument.
String cmd = commandLine.getArguments()[1];
- // Grab apps already on the command (to prevent tab-completed duplicates)
- // FIXME: This does not work.
-// final Set previousApps;
-// if (list.getArguments().length > 2) {
-// previousApps = Sets.newHashSet(
-// Arrays.copyOfRange(list.getArguments(), 2, list.getArguments().length));
-// } else {
-// previousApps = Collections.emptySet();
-// }
-
// Fetch our service and feed it's offerings to the string completer
ApplicationService service = get(ApplicationService.class);
Iterator<Application> it = service.getApplications().iterator();
SortedSet<String> strings = delegate.getStrings();
- while (it.hasNext()) {
- Application app = it.next();
- ApplicationState state = service.getState(app.id());
-// if (previousApps.contains(app.id().name())) {
-// continue;
-// }
- if ("uninstall".equals(cmd) || "download".equals(cmd) ||
- ("activate".equals(cmd) && state == INSTALLED) ||
- ("deactivate".equals(cmd) && state == ACTIVE)) {
- strings.add(app.id().name());
+ if ("install".equals(cmd)) {
+ it = service.getRegisteredApplications().iterator();
+ while (it.hasNext()) {
+ strings.add(it.next().id().name());
+ }
+ } else {
+ while (it.hasNext()) {
+ Application app = it.next();
+ ApplicationState state = service.getState(app.id());
+ if ("uninstall".equals(cmd) || "download".equals(cmd) ||
+ ("activate".equals(cmd) && state == INSTALLED) ||
+ ("deactivate".equals(cmd) && state == ACTIVE)) {
+ strings.add(app.id().name());
+ }
}
}