package org.safehaus.kiskis.mgmt.cli.commands;

import org.apache.felix.gogo.commands.Command;
import org.apache.karaf.shell.console.OsgiCommandSupport;
import org.safehaus.kiskis.mgmt.api.cassandra.Cassandra;
import org.safehaus.kiskis.mgmt.api.cassandra.Config;
import org.safehaus.kiskis.mgmt.api.tracker.Tracker;

import java.util.List;


/**
 * Displays the last log entries
 */
@Command(scope = "cassandra", name = "list-clusters", description = "mydescription")
public class ListClustersCommand extends OsgiCommandSupport {

    private static Cassandra cassandraManager;
    private static Tracker tracker;

    public Tracker getTracker() {
        return tracker;
    }

    public void setTracker(Tracker tracker) {
        ListClustersCommand.tracker = tracker;
    }

    public void setCassandraManager(Cassandra cassandraManager) {
        ListClustersCommand.cassandraManager = cassandraManager;
    }

    public static Cassandra getCassandraManager() {
        return cassandraManager;
    }

    protected Object doExecute() {
        List<Config> list = cassandraManager.getClusters();
        if (list.size() > 0) {
            StringBuilder sb = new StringBuilder();

            for (Config config : list) {
                sb.append(config.getClusterName()).append("\n");
            }
            System.out.println(sb.toString());
        } else System.out.println("No clusters found...");

        return null;
    }
}

@@ -450,21 +450,43 @@
  = %22
-mydescription
+Gets the list of Cassandra clusters
 %22)%0Ap

Code refactor.