blob: 4ab8e9338555e1c5585f18f8a495bfafb429bf46 [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;
Ray Milkey32ce0ed2018-10-10 15:39:24 -070019import org.apache.karaf.shell.api.action.lifecycle.Service;
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 */
Ray Milkey32ce0ed2018-10-10 15:39:24 -070029@Service
Luca Pretedce16f82016-11-22 13:11:56 -080030public class VplsCommandCompleter extends AbstractChoicesCompleter {
31
32 @Override
33 public List<String> choices() {
Ray Milkey86ad7bb2018-09-27 12:32:28 -070034 if (commandLine.getArguments() == null) {
Yi Tsengf4e13e32017-03-30 15:38:39 -070035 return Collections.emptyList();
36 }
Ray Milkey86ad7bb2018-09-27 12:32:28 -070037 List<String> argList = Lists.newArrayList();
38
Luca Pretedce16f82016-11-22 13:11:56 -080039 String argOne = null;
Yi Tsengf4e13e32017-03-30 15:38:39 -070040 if (argList.size() > 1) {
41 argOne = argList.get(1);
Luca Pretedce16f82016-11-22 13:11:56 -080042 }
43 VplsCommandEnum vplsCommandEnum = VplsCommandEnum.enumFromString(argOne);
44 if (vplsCommandEnum != null) {
45 switch (vplsCommandEnum) {
46 case CREATE:
Luca Pretedce16f82016-11-22 13:11:56 -080047 case LIST:
48 return Collections.emptyList();
49 default:
50 VplsCommandEnum.toStringList();
51 }
52 }
53 return VplsCommandEnum.toStringList();
54 }
55}