Added an intent completer to the command-line.
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/IntentIdCompleter.java b/cli/src/main/java/org/onlab/onos/cli/net/IntentIdCompleter.java
new file mode 100644
index 0000000..5e217d6
--- /dev/null
+++ b/cli/src/main/java/org/onlab/onos/cli/net/IntentIdCompleter.java
@@ -0,0 +1,34 @@
+package org.onlab.onos.cli.net;
+
+import org.apache.karaf.shell.console.Completer;
+import org.apache.karaf.shell.console.completer.StringsCompleter;
+import org.onlab.onos.cli.AbstractShellCommand;
+import org.onlab.onos.net.intent.Intent;
+import org.onlab.onos.net.intent.IntentService;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.SortedSet;
+
+/**
+ * Intent ID completer.
+ */
+public class IntentIdCompleter implements Completer {
+ @Override
+ public int complete(String buffer, int cursor, List<String> candidates) {
+ // Delegate string completer
+ StringsCompleter delegate = new StringsCompleter();
+
+ // Fetch our service and feed it's offerings to the string completer
+ IntentService service = AbstractShellCommand.get(IntentService.class);
+ Iterator<Intent> it = service.getIntents().iterator();
+ SortedSet<String> strings = delegate.getStrings();
+ while (it.hasNext()) {
+ strings.add(it.next().getId().toString());
+ }
+
+ // Now let the completer do the work for figuring out what to offer.
+ return delegate.complete(buffer, cursor, candidates);
+ }
+
+}
diff --git a/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
index 17a9e29..9ed8a47 100644
--- a/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ b/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -58,6 +58,9 @@
</command>
<command>
+ <action class="org.onlab.onos.cli.net.IntentsListCommand"/>
+ </command>
+ <command>
<action class="org.onlab.onos.cli.net.AddHostToHostIntentCommand"/>
<completers>
<ref component-id="hostIdCompleter"/>
@@ -65,9 +68,9 @@
</command>
<command>
<action class="org.onlab.onos.cli.net.RemoveHostToHostIntentCommand"/>
- </command>
- <command>
- <action class="org.onlab.onos.cli.net.IntentsListCommand"/>
+ <completers>
+ <ref component-id="intentIdCompleter"/>
+ </completers>
</command>
<command>
@@ -108,6 +111,7 @@
<bean id="clusterIdCompleter" class="org.onlab.onos.cli.net.ClusterIdCompleter"/>
<bean id="roleCompleter" class="org.onlab.onos.cli.net.RoleCompleter"/>
<bean id="hostIdCompleter" class="org.onlab.onos.cli.net.HostIdCompleter"/>
+ <bean id="intentIdCompleter" class="org.onlab.onos.cli.net.IntentIdCompleter"/>
<bean id="flowRuleStatusCompleter" class="org.onlab.onos.cli.net.FlowRuleStatusCompleter"/>
</blueprint>