karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [15/33] git commit: [KARAF-2901] Add an option to show bundle version in bundle:tree-show
Date Fri, 11 Apr 2014 17:20:37 GMT
[KARAF-2901] Add an option to show bundle version in bundle:tree-show


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/6727c1b7
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/6727c1b7
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/6727c1b7

Branch: refs/heads/master
Commit: 6727c1b74a83006c9c2aac98ecfb6daf5d4be928
Parents: edd82fd
Author: Guillaume Nodet <gnodet@gmail.com>
Authored: Fri Apr 11 19:17:49 2014 +0200
Committer: Guillaume Nodet <gnodet@gmail.com>
Committed: Fri Apr 11 19:20:04 2014 +0200

----------------------------------------------------------------------
 .../karaf/bundle/command/ShowBundleTree.java      | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/6727c1b7/bundle/core/src/main/java/org/apache/karaf/bundle/command/ShowBundleTree.java
----------------------------------------------------------------------
diff --git a/bundle/core/src/main/java/org/apache/karaf/bundle/command/ShowBundleTree.java
b/bundle/core/src/main/java/org/apache/karaf/bundle/command/ShowBundleTree.java
index a83ce39..f6f3d48 100644
--- a/bundle/core/src/main/java/org/apache/karaf/bundle/command/ShowBundleTree.java
+++ b/bundle/core/src/main/java/org/apache/karaf/bundle/command/ShowBundleTree.java
@@ -30,6 +30,7 @@ import org.apache.felix.utils.version.VersionTable;
 import org.apache.karaf.bundle.command.bundletree.Node;
 import org.apache.karaf.bundle.command.bundletree.Tree;
 import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
@@ -52,6 +53,10 @@ import static java.lang.String.format;
 public class ShowBundleTree extends BundleCommand {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(ShowBundleTree.class);
+
+    @Option(name = "-v", aliases = { "--version" }, description = "Show bundle versions")
+    private boolean versions;
+
     private Tree<Bundle> tree;
 
     public ShowBundleTree() {
@@ -104,9 +109,16 @@ public class ShowBundleTree extends BundleCommand {
         tree.write(System.out, new Tree.Converter<Bundle>() {
 
             public String toString(Node<Bundle> node) {
-                return String.format("%s [%s]",
-                                     node.getValue().getSymbolicName(),
-                                     node.getValue().getBundleId());
+                if (versions) {
+                    return String.format("%s / [%s] [%s]",
+                            node.getValue().getSymbolicName(),
+                            node.getValue().getVersion().toString(),
+                            node.getValue().getBundleId());
+                } else {
+                    return String.format("%s [%s]",
+                            node.getValue().getSymbolicName(),
+                            node.getValue().getBundleId());
+                }
             }
         });
     }


Mime
View raw message