blob: 43d79d8699198de7cd4600f88aa65bfb2aedf08e [file] [log] [blame]
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +09001/*
2 * Copyright 2017-present Open Networking Foundation
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 */
16package org.onosproject.simplefabric;
17
18import com.google.common.collect.Lists;
Ray Milkey86ad7bb2018-09-27 12:32:28 -070019import org.apache.karaf.shell.api.action.lifecycle.Service;
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090020import org.onosproject.cli.AbstractChoicesCompleter;
21
22import java.util.List;
23import java.util.Arrays;
24import java.util.Collections;
25
26/**
27 * SimpleFabric command completer.
28 */
Ray Milkey86ad7bb2018-09-27 12:32:28 -070029@Service
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090030public class SimpleFabricCommandCompleter extends AbstractChoicesCompleter {
31
Ray Milkey10f35dc2018-02-01 09:26:51 -080032 private static final List<String> COMMAND_LIST =
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090033 Arrays.asList("show", "intents", "reactive-intents", "refresh", "flush");
34
35 @Override
36 public List<String> choices() {
Ray Milkey86ad7bb2018-09-27 12:32:28 -070037 if (commandLine.getArguments() == null) {
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090038 return Collections.emptyList();
39 }
Ray Milkey86ad7bb2018-09-27 12:32:28 -070040 List<String> argList = Lists.newArrayList(commandLine.getArguments());
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090041 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