geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r404908 - in /geronimo/sandbox/gshell/trunk: gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/ gshell-core/src/main/java/org/apache/geronimo/gshell/command/
Date Mon, 08 May 2006 03:42:52 GMT
Author: jdillon
Date: Sun May  7 20:42:51 2006
New Revision: 404908

URL: http://svn.apache.org/viewcvs?rev=404908&view=rev
Log:
Renamed Variables methods
Changed some debug to info, sinve info is really verbose and disabled by default
Main now uses instance object for simplicity


Modified:
    geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/Command.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/Variables.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/VariablesMap.java

Modified: geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
URL: http://svn.apache.org/viewcvs/geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java?rev=404908&r1=404907&r2=404908&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
Sun May  7 20:42:51 2006
@@ -25,9 +25,6 @@
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.HelpFormatter;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 import org.apache.geronimo.gshell.GShell;
 import org.apache.geronimo.gshell.console.IO;
 
@@ -41,11 +38,29 @@
  */
 public class Main
 {
-    private static void setConsoleLogLevel(final String level) {
+    //
+    // NOTE: Do not use logging from this class, as it is used to configure
+    //       the logging level with System properties, which will only get
+    //       picked up on the initial loading ofr Log4j
+    //
+
+    private ClassWorld world;
+    private IO io = new IO();
+    private boolean interactive = false;
+
+    public Main(final ClassWorld world) {
+        assert world != null;
+        this.world = world;
+
+        // Default is to be quiet
+        setConsoleLogLevel("WARN");
+    }
+
+    private void setConsoleLogLevel(final String level) {
         System.setProperty("gshell.log.console.level", level);
     }
     
-    private static void setPropertyFrom(final String namevalue) {
+    private void setPropertyFrom(final String namevalue) {
         String name, value;
         int j = namevalue.indexOf("=");
         
@@ -61,51 +76,52 @@
         
         System.setProperty(name, value);
     }
-    
-    public static void main(final String[] args, final ClassWorld world) throws Exception
{
+
+    public void run(final String[] args) throws Exception {
         assert args != null;
-        assert world != null;
-        
-        // Default is to be quiet
-        setConsoleLogLevel("WARN");
-        boolean interactive = false;
-        
-        IO io = new IO();
-        
+
         Options options = new Options();
-        
+
         options.addOption(OptionBuilder.withLongOpt("help")
             .withDescription("Display this help message")
             .create('h'));
-        
+
         options.addOption(OptionBuilder.withLongOpt("version")
             .withDescription("Display GShell version")
             .create('V'));
-        
+
         options.addOption(OptionBuilder.withLongOpt("define")
             .withDescription("Define a system property")
             .hasArg()
             .withArgName("name=value")
             .create('D'));
-        
+
         options.addOption(OptionBuilder.withLongOpt("interactive")
             .withDescription("Run in interactive mode")
             .create('i'));
-        
+
+        //
+        // TODO: Add these output modifiers to a seperate group
+        //
+
         options.addOption(OptionBuilder.withLongOpt("debug")
-            .withDescription("Enable DEBUG output")
+            .withDescription("Enable DEBUG logging output")
             .create());
-        
+
         options.addOption(OptionBuilder.withLongOpt("verbose")
-            .withDescription("Enable INFO output")
+            .withDescription("Enable INFO logging output")
             .create());
-        
+
+        options.addOption(OptionBuilder.withLongOpt("quiet")
+            .withDescription("Limit logging output to ERROR")
+            .create());
+
         CommandLineParser parser = new PosixParser();
         CommandLine line = parser.parse(options, args, true);
-        
+
         if (line.hasOption('h')) {
             io.out.println(Banner.getBanner());
-            
+
             HelpFormatter formatter = new HelpFormatter();
             formatter.printHelp(
                 io.out,
@@ -117,55 +133,57 @@
                 4, // desc pad
                 "",
                 false); // auto usage
-            
+
             io.out.println();
             io.out.flush();
-            
+
             System.exit(0);
         }
-        
+
         if (line.hasOption('V')) {
             io.out.println(Banner.getBanner());
             io.out.println(Version.getInstance());
             io.out.println();
             io.out.flush();
-            
+
             System.exit(0);
         }
-        
+
         if (line.hasOption('D')) {
             String[] values = line.getOptionValues('D');
-            
+
             for (int i=0; i<values.length; i++) {
                 setPropertyFrom(values[i]);
             }
         }
-        
-        // If --debug is set it wins over --verbose
+
+        if (line.hasOption("quiet")) {
+            setConsoleLogLevel("ERROR");
+        }
         if (line.hasOption("debug")) {
             setConsoleLogLevel("DEBUG");
         }
         else if (line.hasOption("verbose")) {
             setConsoleLogLevel("INFO");
         }
-        
+
         if (line.hasOption('i')) {
             interactive = true;
         }
-        
+
         //
         // TODO: Need to pass GShell the ClassWorld, so that the application can add to it
if needed
         //
-        
+
         // Startup the shell
         GShell gshell = new GShell(io);
         String[] _args = line.getArgs();
-        
+
         // Force interactive if there are no args
         if (_args.length == 0) {
             interactive = true;
         }
-        
+
         if (interactive) {
             //
             // TODO: Need to check if there are args, and run them and then enter interactive
@@ -176,10 +194,18 @@
             int status = gshell.execute(_args);
             System.exit(status);
         }
-        
+
         //
         // TODO: Run interactive
         //
+    }
+    
+    public static void main(final String[] args, final ClassWorld world) throws Exception
{
+        assert args != null;
+        assert world != null;
+
+        Main main = new Main(world);
+        main.run(args);
     }
     
     public static void main(final String[] args) throws Exception {

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/Command.java
URL: http://svn.apache.org/viewcvs/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/Command.java?rev=404908&r1=404907&r2=404908&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/Command.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/Command.java
Sun May  7 20:42:51 2006
@@ -38,4 +38,14 @@
     void abort(); // throws Exception ?
     
     void destroy(); // throws Exception ?
+
+    //
+    // 'help' command helpers to allow external inspection of command help
+    //
+
+    // String usage() // single line used to render help page
+
+    // String about() // single line to describe the command
+
+    // String help() // full help page (includes usage + about + command line options)
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
URL: http://svn.apache.org/viewcvs/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java?rev=404908&r1=404907&r2=404908&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
Sun May  7 20:42:51 2006
@@ -130,13 +130,9 @@
         
         // Make sure that we have been initialized before we go any further
         ensureInitialized();
-        
-        boolean debug = log.isDebugEnabled();
-        
-        if (debug) {
-            log.debug("Executing w/arguments: " + java.util.Arrays.asList(args));
-        }
-        
+
+        log.info("Executing w/arguments: " + java.util.Arrays.asList(args));
+
         int status;
         
         try {
@@ -144,7 +140,7 @@
         }
         catch (Exception e) {
             log.error(e.getMessage());
-            if (debug) {
+            if (log.isDebugEnabled()) {
                 log.debug("Failure details", e);
             }
             
@@ -154,11 +150,9 @@
             // Be sure to flush the commands outputs
             getIO().flush();
         }
-        
-        if (debug) {
-            log.debug("Command exited with status code: " + status);
-        }
-        
+
+        log.info("Command exited with status code: " + status);
+
         return status;
     }
     

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/Variables.java
URL: http://svn.apache.org/viewcvs/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/Variables.java?rev=404908&r1=404907&r2=404908&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/Variables.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/Variables.java
Sun May  7 20:42:51 2006
@@ -29,9 +29,9 @@
     
     Object get(String name);
     
-    void remove(String name);
+    void unset(String name);
     
-    boolean isSet(String name);
+    boolean contains(String name);
     
     Iterator names();
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/VariablesMap.java
URL: http://svn.apache.org/viewcvs/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/VariablesMap.java?rev=404908&r1=404907&r2=404908&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/VariablesMap.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/VariablesMap.java
Sun May  7 20:42:51 2006
@@ -52,13 +52,13 @@
         return map.get(name);
     }
     
-    public void remove(final String name) {
+    public void unset(final String name) {
         assert name != null;
         
         map.remove(name);
     }
     
-    public boolean isSet(final String name) {
+    public boolean contains(final String name) {
         assert name != null;
         
         return map.containsKey(name);



Mime
View raw message