blob: 2b90f66d5eef477cefdb7751fd2b24e7c4f5e1ab [file] [log] [blame]
Thomas Vachuska90b453f2015-01-30 18:57:14 -08001/*
2 * Copyright 2015 Open Networking Laboratory
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.cli.app;
17
18import org.apache.karaf.shell.commands.Command;
19import org.onosproject.app.ApplicationService;
20import org.onosproject.cli.AbstractShellCommand;
21import org.onosproject.core.Application;
22
23import static org.onosproject.app.ApplicationState.ACTIVE;
24
25/**
26 * Lists application information.
27 */
28@Command(scope = "onos", name = "apps",
29 description = "Lists application information")
30public class ApplicationsListCommand extends AbstractShellCommand {
31
32 private static final String FMT =
33 "%s id=%d, name=%s, version=%s, origin=%s, description=%s, " +
34 "features=%s, featuresRepo=%s, permissions=%s";
35
36 @Override
37 protected void execute() {
38 ApplicationService service = get(ApplicationService.class);
39 for (Application app : service.getApplications()) {
40 print(FMT, service.getState(app.id()) == ACTIVE ? "*" : " ",
41 app.id().id(), app.id().name(), app.version(), app.origin(),
42 app.description(), app.features(), app.featuresRepo(), app.permissions());
43 }
44 }
45
46}