You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2012/05/07 14:54:49 UTC
svn commit: r1334992 -
/karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java
Author: jbonofre
Date: Mon May 7 12:54:49 2012
New Revision: 1334992
URL: http://svn.apache.org/viewvc?rev=1334992&view=rev
Log:
[KARAF-1337] Mimic config:list output in cluster:config-list
Modified:
karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java
Modified: karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java?rev=1334992&r1=1334991&r2=1334992&view=diff
==============================================================================
--- karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java (original)
+++ karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java Mon May 7 12:54:49 2012
@@ -13,23 +13,26 @@
*/
package org.apache.karaf.cellar.config.shell;
+import org.apache.felix.gogo.commands.Option;
import org.apache.karaf.cellar.config.Constants;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
+import java.util.Enumeration;
import java.util.Map;
import java.util.Properties;
@Command(scope = "cluster", name = "config-list", description = "List the configuration PIDs assigned to a group")
public class ListCommand extends ConfigCommandSupport {
- protected static final String OUTPUT_FORMAT = "%-40s";
-
@Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
String groupName;
+ @Option(name = "-m", aliases = { "--minimal" }, description = "Don't display the properties of each configuration", required = false, multiValued = false)
+ boolean minimal;
+
@Override
protected Object doExecute() throws Exception {
// check if the group exists
@@ -39,15 +42,24 @@ public class ListCommand extends ConfigC
return null;
}
- Map<String, Properties> configurationTable = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ Map<String, Properties> configurationDistributedMap = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
- if (configurationTable != null && !configurationTable.isEmpty()) {
- System.out.println(String.format("Configuration PIDs for group " + groupName));
- System.out.println(String.format(OUTPUT_FORMAT, "PID"));
- for (String pid : configurationTable.keySet()) {
- System.out.println(String.format(OUTPUT_FORMAT, pid));
+ if (configurationDistributedMap != null && !configurationDistributedMap.isEmpty()) {
+ for (String pid : configurationDistributedMap.keySet()) {
+ System.out.println("----------------------------------------------------------------");
+ System.out.println("Pid: " + pid);
+ if (!minimal) {
+ Properties properties = configurationDistributedMap.get(pid);
+ if (properties != null) {
+ System.out.println("Properties:");
+ for (Enumeration e = properties.keys(); e.hasMoreElements();) {
+ Object key = e.nextElement();
+ System.out.println(" " + key + " = " + properties.get(key));
+ }
+ }
+ }
}
- } else System.err.println("No configuration PID found for group " + groupName);
+ } else System.err.println("No configuration PID found for cluster group " + groupName);
return null;
}