Committed by
Gerrit Code Review
Implement groups CLI command autocompletion
Change-Id: I0bb9eff30c03a5d08f69280879ec2be869cb6539
Showing
3 changed files
with
45 additions
and
0 deletions
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.cli.net; | ||
17 | + | ||
18 | +import com.google.common.collect.Lists; | ||
19 | +import org.onosproject.cli.AbstractChoicesCompleter; | ||
20 | +import org.onosproject.net.group.Group; | ||
21 | + | ||
22 | +import java.util.List; | ||
23 | + | ||
24 | +/** | ||
25 | + * Group status completer. | ||
26 | + */ | ||
27 | +public class GroupStatusCompleter extends AbstractChoicesCompleter { | ||
28 | + @Override | ||
29 | + protected List<String> choices() { | ||
30 | + List<String> strings = Lists.newArrayList(); | ||
31 | + for (Group.GroupState groupState : Group.GroupState.values()) { | ||
32 | + strings.add(groupState.toString()); | ||
33 | + } | ||
34 | + strings.add(GroupsListCommand.ANY); | ||
35 | + return strings; | ||
36 | + } | ||
37 | +} |
... | @@ -45,6 +45,8 @@ import static com.google.common.collect.Lists.newArrayList; | ... | @@ -45,6 +45,8 @@ import static com.google.common.collect.Lists.newArrayList; |
45 | description = "Lists all groups in the system") | 45 | description = "Lists all groups in the system") |
46 | public class GroupsListCommand extends AbstractShellCommand { | 46 | public class GroupsListCommand extends AbstractShellCommand { |
47 | 47 | ||
48 | + public static final String ANY = "any"; | ||
49 | + | ||
48 | private static final String FORMAT = | 50 | private static final String FORMAT = |
49 | " id=0x%s, state=%s, type=%s, bytes=%s, packets=%s, appId=%s"; | 51 | " id=0x%s, state=%s, type=%s, bytes=%s, packets=%s, appId=%s"; |
50 | private static final String BUCKET_FORMAT = | 52 | private static final String BUCKET_FORMAT = | ... | ... |
... | @@ -428,6 +428,11 @@ | ... | @@ -428,6 +428,11 @@ |
428 | </command> | 428 | </command> |
429 | <command> | 429 | <command> |
430 | <action class="org.onosproject.cli.net.GroupsListCommand"/> | 430 | <action class="org.onosproject.cli.net.GroupsListCommand"/> |
431 | + <completers> | ||
432 | + <ref component-id="groupStatusCompleter"/> | ||
433 | + <ref component-id="deviceIdCompleter"/> | ||
434 | + <null/> | ||
435 | + </completers> | ||
431 | </command> | 436 | </command> |
432 | 437 | ||
433 | <command> | 438 | <command> |
... | @@ -562,6 +567,7 @@ | ... | @@ -562,6 +567,7 @@ |
562 | <bean id="hostIdCompleter" class="org.onosproject.cli.net.HostIdCompleter"/> | 567 | <bean id="hostIdCompleter" class="org.onosproject.cli.net.HostIdCompleter"/> |
563 | <bean id="intentKeyCompleter" class="org.onosproject.cli.net.IntentKeyCompleter"/> | 568 | <bean id="intentKeyCompleter" class="org.onosproject.cli.net.IntentKeyCompleter"/> |
564 | <bean id="flowRuleStatusCompleter" class="org.onosproject.cli.net.FlowRuleStatusCompleter"/> | 569 | <bean id="flowRuleStatusCompleter" class="org.onosproject.cli.net.FlowRuleStatusCompleter"/> |
570 | + <bean id="groupStatusCompleter" class="org.onosproject.cli.net.GroupStatusCompleter" /> | ||
565 | <bean id="connectPointCompleter" class="org.onosproject.cli.net.ConnectPointCompleter"/> | 571 | <bean id="connectPointCompleter" class="org.onosproject.cli.net.ConnectPointCompleter"/> |
566 | <bean id="nullCompleter" class="org.apache.karaf.shell.console.completer.NullCompleter"/> | 572 | <bean id="nullCompleter" class="org.apache.karaf.shell.console.completer.NullCompleter"/> |
567 | <bean id="ethTypeCompleter" class="org.onosproject.cli.net.EthTypeCompleter"/> | 573 | <bean id="ethTypeCompleter" class="org.onosproject.cli.net.EthTypeCompleter"/> | ... | ... |
-
Please register or login to post a comment