karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject svn commit: r1054644 - in /karaf/trunk/features/command/src/main/java/org/apache/karaf/features/command: InstallFeatureCommand.java UninstallFeatureCommand.java
Date Mon, 03 Jan 2011 15:14:51 GMT
Author: jbonofre
Date: Mon Jan  3 15:14:51 2011
New Revision: 1054644

URL: http://svn.apache.org/viewvc?rev=1054644&view=rev
Log:
[KARAF-353] features:install and features:uninstall command now support multivalued argument.

Modified:
    karaf/trunk/features/command/src/main/java/org/apache/karaf/features/command/InstallFeatureCommand.java
    karaf/trunk/features/command/src/main/java/org/apache/karaf/features/command/UninstallFeatureCommand.java

Modified: karaf/trunk/features/command/src/main/java/org/apache/karaf/features/command/InstallFeatureCommand.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/command/src/main/java/org/apache/karaf/features/command/InstallFeatureCommand.java?rev=1054644&r1=1054643&r2=1054644&view=diff
==============================================================================
--- karaf/trunk/features/command/src/main/java/org/apache/karaf/features/command/InstallFeatureCommand.java
(original)
+++ karaf/trunk/features/command/src/main/java/org/apache/karaf/features/command/InstallFeatureCommand.java
Mon Jan  3 15:14:51 2011
@@ -17,6 +17,7 @@
 package org.apache.karaf.features.command;
 
 import java.util.EnumSet;
+import java.util.List;
 
 import org.apache.felix.gogo.commands.Option;
 import org.apache.karaf.features.FeaturesService;
@@ -28,10 +29,8 @@ public class InstallFeatureCommand exten
 
     private static String DEFAULT_VERSION = "0.0.0";
 
-    @Argument(index = 0, name = "name", description = "The name of the feature", required
= true, multiValued = false)
-    String name;
-    @Argument(index = 1, name = "version", description = "The version of the feature", required
= false, multiValued = false)
-    String version;
+    @Argument(index = 0, name = "feature", description = "The name and version of the features
to uninstall. A feature id looks like name/version. The version is optional.", required =
true, multiValued = true)
+    List<String> features;
     @Option(name = "-c", aliases = "--no-clean", description = "Do not uninstall bundles
on failure", required = false, multiValued = false)
     boolean noClean;
     @Option(name = "-r", aliases = "--no-auto-refresh", description = "Do not automatically
refresh bundles", required = false, multiValued = false)
@@ -40,19 +39,27 @@ public class InstallFeatureCommand exten
     boolean verbose;
 
     protected void doExecute(FeaturesService admin) throws Exception {
-    	if (version == null || version.length() == 0) {
-            version = DEFAULT_VERSION;
-    	}
-        EnumSet<FeaturesService.Option> options = EnumSet.of(FeaturesService.Option.PrintBundlesToRefresh);
-        if (noRefresh) {
-            options.add(FeaturesService.Option.NoAutoRefreshBundles);
+        for (String feature : features) {
+            String[] split = feature.split("/");
+            String name = split[0];
+            String version = null;
+            if (split.length == 2) {
+                version = split[1];
+            }
+    	    if (version == null || version.length() == 0) {
+                version = DEFAULT_VERSION;
+    	    }
+            EnumSet<FeaturesService.Option> options = EnumSet.of(FeaturesService.Option.PrintBundlesToRefresh);
+            if (noRefresh) {
+                options.add(FeaturesService.Option.NoAutoRefreshBundles);
+            }
+            if (noClean) {
+                options.add(FeaturesService.Option.NoCleanIfFailure);
+            }
+            if (verbose) {
+                options.add(FeaturesService.Option.Verbose);
+            }
+            admin.installFeature(name, version, options);
         }
-        if (noClean) {
-            options.add(FeaturesService.Option.NoCleanIfFailure);
-        }
-        if (verbose) {
-            options.add(FeaturesService.Option.Verbose);
-        }
-        admin.installFeature(name, version, options);
     }
 }

Modified: karaf/trunk/features/command/src/main/java/org/apache/karaf/features/command/UninstallFeatureCommand.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/command/src/main/java/org/apache/karaf/features/command/UninstallFeatureCommand.java?rev=1054644&r1=1054643&r2=1054644&view=diff
==============================================================================
--- karaf/trunk/features/command/src/main/java/org/apache/karaf/features/command/UninstallFeatureCommand.java
(original)
+++ karaf/trunk/features/command/src/main/java/org/apache/karaf/features/command/UninstallFeatureCommand.java
Mon Jan  3 15:14:51 2011
@@ -20,20 +20,28 @@ import org.apache.felix.gogo.commands.Ar
 import org.apache.felix.gogo.commands.Command;
 import org.apache.karaf.features.FeaturesService;
 
+import java.util.List;
+
 @Command(scope = "features", name = "uninstall", description = "Uninstalls a feature with
the specified name and version.")
 public class UninstallFeatureCommand extends FeaturesCommandSupport {
 
-    @Argument(index = 0, name = "name", description = "The name of the feature", required
= true, multiValued = false)
-    String name;
-    
-    @Argument(index = 1, name = "version", description = "The version of the feature", required
= false, multiValued = false)
-    String version;
+    @Argument(index = 0, name = "features", description = "The name and version of the features
to uninstall. A feature id looks like name/version. The version is optional.", required =
true, multiValued = true)
+    List<String> features;
 
     protected void doExecute(FeaturesService admin) throws Exception {
-    	if (version != null && version.length() > 0) {
-    		admin.uninstallFeature(name, version);
-    	} else {
-    		admin.uninstallFeature(name );
-    	}
+        // iterate in the provided feature
+        for (String feature : features) {
+            String[] split = feature.split("/");
+            String name = split[0];
+            String version = null;
+            if (split.length == 2) {
+                version = split[1];
+            }
+    	    if (version != null && version.length() > 0) {
+    		    admin.uninstallFeature(name, version);
+    	    } else {
+    		    admin.uninstallFeature(name );
+    	    }
+        }
     }
 }



Mime
View raw message