blob: 0a42609e10b344d08b3ba23ef13281f27b2f08d8 [file] [log] [blame]
daniel park719e5102018-03-06 15:16:39 +09001/*
2 * Copyright 2018-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.openstacknetworking.cli;
17
18
19import org.apache.karaf.shell.console.Completer;
20import org.apache.karaf.shell.console.completer.StringsCompleter;
21
22import java.util.List;
23import java.util.SortedSet;
24
25/**
26 * OpenStack end point completer.
27 */
28public class OpenStackEndPointCompleter implements Completer {
29
Jian Li8769d5b2018-03-09 21:55:40 +090030 private static final String OPENSTACK_ENDPOINT_EXAMPLE_V2 =
Jian Li8cbc3b92018-04-11 12:21:25 +090031 "http://IP address of OpenStack end point:35357/v2.0 ProjectName ID Password [Perspective]";
Jian Li8769d5b2018-03-09 21:55:40 +090032 private static final String OPENSTACK_ENDPOINT_EXAMPLE_V3 =
Jian Li8cbc3b92018-04-11 12:21:25 +090033 "http://IP address of OpenStack end point/identity/v3 ProjectName ID Password [Perspective]";
Jian Li8769d5b2018-03-09 21:55:40 +090034 private static final String SEPARATOR = "\n or \n";
35
daniel park719e5102018-03-06 15:16:39 +090036 @Override
37 public int complete(String buffer, int cursor, List<String> candidates) {
38 StringsCompleter delegate = new StringsCompleter();
39
40 SortedSet<String> strings = delegate.getStrings();
41
Jian Li8769d5b2018-03-09 21:55:40 +090042 strings.add(OPENSTACK_ENDPOINT_EXAMPLE_V2);
43 strings.add(SEPARATOR);
44 strings.add(OPENSTACK_ENDPOINT_EXAMPLE_V3);
daniel park719e5102018-03-06 15:16:39 +090045
46 return delegate.complete(buffer, cursor, candidates);
47 }
48}