blob: a0cdc99fb354fe8659bf3703b05640c3bc76f802 [file] [log] [blame]
Luca Pretedce16f82016-11-22 13:11:56 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Luca Pretedce16f82016-11-22 13:11:56 -08003 *
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 */
16package org.onosproject.vpls.cli.completer;
17
18import com.google.common.collect.Lists;
Yi Tsengf4e13e32017-03-30 15:38:39 -070019import org.apache.karaf.shell.console.completer.ArgumentCompleter;
Luca Pretedce16f82016-11-22 13:11:56 -080020import org.onosproject.cli.AbstractChoicesCompleter;
21import org.onosproject.vpls.cli.VplsCommandEnum;
22
23import java.util.Collections;
24import java.util.List;
25
26/**
27 * VPLS command completer.
28 */
29public class VplsCommandCompleter extends AbstractChoicesCompleter {
30
31 @Override
32 public List<String> choices() {
Yi Tsengf4e13e32017-03-30 15:38:39 -070033 ArgumentCompleter.ArgumentList argumentList = getArgumentList();
34 if (argumentList == null) {
35 return Collections.emptyList();
36 }
37 List<String> argList = Lists.newArrayList(argumentList.getArguments());
Luca Pretedce16f82016-11-22 13:11:56 -080038 String argOne = null;
Yi Tsengf4e13e32017-03-30 15:38:39 -070039 if (argList.size() > 1) {
40 argOne = argList.get(1);
Luca Pretedce16f82016-11-22 13:11:56 -080041 }
42 VplsCommandEnum vplsCommandEnum = VplsCommandEnum.enumFromString(argOne);
43 if (vplsCommandEnum != null) {
44 switch (vplsCommandEnum) {
45 case CREATE:
Luca Pretedce16f82016-11-22 13:11:56 -080046 case LIST:
47 return Collections.emptyList();
48 default:
49 VplsCommandEnum.toStringList();
50 }
51 }
52 return VplsCommandEnum.toStringList();
53 }
54}