blob: d216bac704dfdff9e8be5fb5410d95afff59270e [file] [log] [blame]
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +09001/*
Jian Li8df54a92018-08-23 17:01:31 +09002 * Copyright 2018-present Open Networking Foundation
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +09003 *
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 */
Jian Li8df54a92018-08-23 17:01:31 +090016package org.onosproject.simplefabric.cli;
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090017
18import com.google.common.collect.Lists;
19import org.apache.karaf.shell.console.completer.ArgumentCompleter;
20import org.onosproject.cli.AbstractChoicesCompleter;
21
22import java.util.List;
23import java.util.Arrays;
24import java.util.Collections;
25
26/**
27 * SimpleFabric command completer.
28 */
29public class SimpleFabricCommandCompleter extends AbstractChoicesCompleter {
30
Ray Milkey10f35dc2018-02-01 09:26:51 -080031 private static final List<String> COMMAND_LIST =
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090032 Arrays.asList("show", "intents", "reactive-intents", "refresh", "flush");
33
34 @Override
35 public List<String> choices() {
36 ArgumentCompleter.ArgumentList argumentList = getArgumentList();
37 if (argumentList == null) {
38 return Collections.emptyList();
39 }
40 List<String> argList = Lists.newArrayList(argumentList.getArguments());
41 String argOne = null;
42 if (argList.size() > 1) {
43 argOne = argList.get(1);
44 }
45 if (COMMAND_LIST.contains(argOne)) {
46 return Collections.emptyList();
47 } else {
48 return COMMAND_LIST;
49 }
50 }
51}
52