Thomas Vachuska | 90b453f | 2015-01-30 18:57:14 -0800 | [diff] [blame^] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.cli.app; |
| 17 | |
| 18 | import org.apache.karaf.shell.commands.Command; |
| 19 | import org.onosproject.app.ApplicationService; |
| 20 | import org.onosproject.cli.AbstractShellCommand; |
| 21 | import org.onosproject.core.Application; |
| 22 | |
| 23 | import static org.onosproject.app.ApplicationState.ACTIVE; |
| 24 | |
| 25 | /** |
| 26 | * Lists application information. |
| 27 | */ |
| 28 | @Command(scope = "onos", name = "apps", |
| 29 | description = "Lists application information") |
| 30 | public 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 | } |