Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2014 Red Hat, Inc. Red Hat licenses this file to you under the Apache License, version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package io.fabric8.commands;
import  org.apache.felix.gogo.commands.Command;
import static;
@Command(name = "version-list", scope = "fabric", description = "List the existing versions")
public class VersionListAction extends AbstractAction {
    private static final String CONSOLE_FORMAT="%-15s %-9s %-14s %s";
    private final FabricService fabricService;
    VersionListAction(FabricService fabricService) {
        this. = fabricService;
    public FabricService getFabricService() {
        return ;
    protected Object doExecute() throws Exception {
        Container[] containers = getFabricService().getContainers();
        Version[] versions = getFabricService().getVersions();
        printVersions(containersversionsgetFabricService().getDefaultVersion(), .);
        return null;
    protected void printVersions(Container[] containersVersion[] versionsVersion defaultVersionPrintStream out) {
        out.println(String.format("[version]""[default]""[# containers]""[description]"));
        // they are sorted in the correct order by default
        for (Version version : versions) {
            boolean isDefault = defaultVersion.getId().equals(version.getId());
            int active = countContainersByVersion(containersversion);
            String description = version.getAttributes().get(.);
            out.println(String.format(version.getId(), (isDefault ? "true" : "false"), active, (description != null ? description : "")));
New to GrepCode? Check out our FAQ X