geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r410873 - /geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/builtin/ExitCommand.java
Date Thu, 01 Jun 2006 14:52:16 GMT
Author: jdillon
Date: Thu Jun  1 07:52:16 2006
New Revision: 410873

URL: http://svn.apache.org/viewvc?rev=410873&view=rev
Log:
Better syntax handling

Modified:
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/builtin/ExitCommand.java

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/builtin/ExitCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/builtin/ExitCommand.java?rev=410873&r1=410872&r2=410873&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/builtin/ExitCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/builtin/ExitCommand.java
Thu Jun  1 07:52:16 2006
@@ -58,7 +58,19 @@
         CommandLineParser parser = new PosixParser();
         CommandLine line = parser.parse(options, args);
 
-        if (line.hasOption('h')) {
+        boolean usage = false;
+        int exitCode = 0;
+
+        if (args.length > 1) {
+            io.err.println("Unexpected arguments: " + Arguments.asString(args));
+            io.err.println();
+            usage = true;
+        }
+        if (args.length == 1) {
+            exitCode = Integer.parseInt(args[0]);
+        }
+
+        if (usage || line.hasOption('h')) {
             io.out.println(getName() + " -- exit the current shell");
             io.out.println();
 
@@ -79,25 +91,12 @@
             return Command.SUCCESS;
         }
 
-        exit(line.getArgs());
-
+        exit(exitCode);
+                
         // Should never get this far
         assert false;
 
         return Command.FAILURE;
-    }
-
-    private void exit(final String[] args) {
-        int exitCode = 0;
-
-        if (args.length > 1) {
-            getIO().err.println("Unexpected arguments: " + Arguments.asString(args));
-        }
-        if (args.length == 1) {
-            exitCode = Integer.parseInt(args[0]);
-        }
-
-        exit(exitCode);
     }
 
     private void exit(final int exitCode) {



Mime
View raw message