geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r417081 - in /geronimo/sandbox/gshell/trunk/gshell-core/src/main: java/org/apache/geronimo/gshell/builtins/SetCommand.java resources/org/apache/geronimo/gshell/builtins/SetCommandMessages.properties
Date Sun, 25 Jun 2006 22:33:15 GMT
Author: jdillon
Date: Sun Jun 25 15:33:13 2006
New Revision: 417081

URL: http://svn.apache.org/viewvc?rev=417081&view=rev
Log:
Display variables or properties when set called w/o args

Modified:
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/SetCommand.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/geronimo/gshell/builtins/SetCommandMessages.properties

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/SetCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/SetCommand.java?rev=417081&r1=417080&r2=417081&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/SetCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/SetCommand.java
Sun Jun 25 15:33:13 2006
@@ -29,6 +29,7 @@
 import org.apache.geronimo.gshell.console.IO;
 
 import java.util.Iterator;
+import java.util.Properties;
 
 /**
  * Set a variable or property.
@@ -44,7 +45,7 @@
         PROPERTY
     }
 
-    private boolean displayVariables;
+    private boolean display;
 
     private Mode mode = Mode.VARIABLE;
 
@@ -75,7 +76,7 @@
         String[] args = line.getArgs();
 
         if (args.length == 0) {
-            displayVariables = true;
+            display = true;
         }
 
         if (line.hasOption('p')) {
@@ -90,19 +91,40 @@
 
         IO io = getIO();
 
-        // No args... list all variables
-        if (displayVariables) {
-            Variables vars = getVariables();
-            Iterator<String> iter = vars.names();
-
-            while (iter.hasNext()) {
-                String name = iter.next();
-                Object value = vars.get(name);
-
-                io.out.print(name);
-                io.out.print("=");
-                io.out.print(value);
-                io.out.println();
+        // No args... list all properties or variables
+        if (display) {
+            switch (mode) {
+                case PROPERTY: {
+                    Properties props = System.getProperties();
+                    Iterator iter = props.keySet().iterator();
+
+                    while (iter.hasNext()) {
+                        String name = (String)iter.next();
+                        String value = props.getProperty(name);
+
+                        io.out.print(name);
+                        io.out.print("=");
+                        io.out.print(value);
+                        io.out.println();
+                    }
+                    break;
+                }
+
+                case VARIABLE: {
+                    Variables vars = getVariables();
+                    Iterator<String> iter = vars.names();
+
+                    while (iter.hasNext()) {
+                        String name = iter.next();
+                        Object value = vars.get(name);
+
+                        io.out.print(name);
+                        io.out.print("=");
+                        io.out.print(value);
+                        io.out.println();
+                    }
+                    break;
+                }
             }
 
             return Command.SUCCESS;

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/geronimo/gshell/builtins/SetCommandMessages.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/geronimo/gshell/builtins/SetCommandMessages.properties?rev=417081&r1=417080&r2=417081&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/geronimo/gshell/builtins/SetCommandMessages.properties
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/geronimo/gshell/builtins/SetCommandMessages.properties
Sun Jun 25 15:33:13 2006
@@ -16,4 +16,4 @@
 
 cli.usage.description=Set a variable or property
 
-cli.usage.footer=With no arguments, current variables are displayed as name=value
\ No newline at end of file
+cli.usage.footer=With no arguments, current variables (or properties) are displayed as name=value
\ No newline at end of file



Mime
View raw message