geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r535507 [3/4] - in /geronimo/server/trunk: assemblies/geronimo-boilerplate-minimal/ configs/client-system/ configs/j2ee-system/ configs/jsr88-cli/ configs/online-deployer/ modules/geronimo-cli/ modules/geronimo-cli/src/ modules/geronimo-cli...
Date Sat, 05 May 2007 11:22:52 GMT
Added: geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/deployer/ListModulesCommandArgsTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/deployer/ListModulesCommandArgsTest.java?view=auto&rev=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/deployer/ListModulesCommandArgsTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-cli/src/test/java/org/apache/geronimo/cli/deployer/ListModulesCommandArgsTest.java Sat May  5 04:22:39 2007
@@ -0,0 +1,80 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev:385659 $ $Date: 2007-03-07 14:40:07 +1100 (Wed, 07 Mar 2007) $
+ */
+public class ListModulesCommandArgsTest extends TestCase {
+
+    public void testArgs() throws Exception {
+        ListModulesCommandArgs args = new ListModulesCommandArgs(new String[] {"--all", "arg1", "arg2"});
+        String[] theArgs = args.getArgs();
+        assertEquals(2 , theArgs.length);
+        assertEquals("arg1" , theArgs[0]);
+        assertEquals("arg2" , theArgs[1]);
+    }
+
+    public void testAll() throws Exception {
+        ListModulesCommandArgs args = new ListModulesCommandArgs(new String[] {"--all"});
+        assertTrue(args.isAll());
+
+        args = new ListModulesCommandArgs(new String[] {"-a"});
+        assertTrue(args.isAll());
+    }
+
+    public void testStarted() throws Exception {
+        ListModulesCommandArgs args = new ListModulesCommandArgs(new String[] {"--started"});
+        assertTrue(args.isStarted());
+        
+        args = new ListModulesCommandArgs(new String[] {"-s"});
+        assertTrue(args.isStarted());
+    }
+    
+    public void testStopped() throws Exception {
+        ListModulesCommandArgs args = new ListModulesCommandArgs(new String[] {"--stopped"});
+        assertTrue(args.isStopped());
+        
+        args = new ListModulesCommandArgs(new String[] {"-t"});
+        assertTrue(args.isStopped());
+    }
+    
+    public void testStatePermutationsFail() throws Exception {
+        try {
+            new ListModulesCommandArgs(new String[] {"-a", "-s"});
+            fail();
+        } catch (CLParserException e) {
+        }
+        
+        try {
+            new ListModulesCommandArgs(new String[] {"-a", "-t"});
+            fail();
+        } catch (CLParserException e) {
+        }
+        
+        try {
+            new ListModulesCommandArgs(new String[] {"-s", "-t"});
+            fail();
+        } catch (CLParserException e) {
+        }
+    }
+    
+}

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/pom.xml?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/pom.xml Sat May  5 04:22:39 2007
@@ -45,6 +45,12 @@
             <artifactId>geronimo-service-builder</artifactId>
             <version>${version}</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-cli</artifactId>
+            <version>${version}</version>
+        </dependency>
         
         <dependency>
             <groupId>org.apache.geronimo.modules</groupId>

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java Sat May  5 04:22:39 2007
@@ -39,33 +39,9 @@
  * @version $Rev$ $Date$
  */
 public abstract class AbstractCommand implements DeployCommand {
-    private String command;
-    private String group;
-    private String helpArgumentList;
-    private String helpText;
     private PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
 
-    public AbstractCommand(String command, String group, String helpArgumentList, String helpText) {
-        this.command = command;
-        this.group = group;
-        this.helpArgumentList = helpArgumentList;
-        this.helpText = helpText;
-    }
-
-    public String getCommandName() {
-        return command;
-    }
-
-    public String getHelpArgumentList() {
-        return helpArgumentList;
-    }
-
-    public String getHelpText() {
-        return helpText;
-    }
-
-    public String getCommandGroup() {
-        return group;
+    public AbstractCommand() {
     }
 
     public boolean isLocalOnly() {

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDeploy.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDeploy.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDeploy.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDeploy.java Sat May  5 04:22:39 2007
@@ -17,13 +17,14 @@
 
 package org.apache.geronimo.deployment.cli;
 
-import org.apache.geronimo.common.DeploymentException;
+import java.io.File;
+import java.io.PrintWriter;
 
 import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.enterprise.deploy.spi.Target;
 import javax.enterprise.deploy.spi.status.ProgressObject;
-import java.io.File;
-import java.io.PrintWriter;
+
+import org.apache.geronimo.common.DeploymentException;
 
 /**
  * The CLI deployer logic to deploy (distribute plus start).
@@ -31,17 +32,6 @@
  * @version $Rev$ $Date$
  */
 public class CommandDeploy extends CommandDistribute {
-    public CommandDeploy() {
-        super("deploy", "1. Common Commands", "[--inPlace] [--targets target;target;...] [module] [plan]",
-                "Normally both a module and plan are passed to the deployer.  " +
-                "Sometimes the module contains a plan, or requires no plan, in which case " +
-                "the plan may be omitted.  Sometimes the plan references a module already " +
-                "deployed in the Geronimo server environment, in which case a module does " +
-                "not need to be provided.\n" +
-                "If no targets are provided, the module is deployed to all available " +
-                "targets.  Geronimo only provides one target (ever), so this is primarily " +
-                "useful when using a different driver.");
-    }
 
     protected String getAction() {
         return "Deployed";
@@ -56,7 +46,4 @@
         return mgr.start(po.getResultTargetModuleIDs());
     }
 
-    public void execute(PrintWriter out, ServerConnection connection, String[] args) throws DeploymentException {
-        super.execute(out, connection, args);
-    }
 }

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDistribute.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDistribute.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDistribute.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDistribute.java Sat May  5 04:22:39 2007
@@ -19,7 +19,7 @@
 
 import java.io.File;
 import java.io.PrintWriter;
-import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.StringTokenizer;
 
@@ -28,6 +28,8 @@
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.enterprise.deploy.spi.status.ProgressObject;
 
+import org.apache.geronimo.cli.deployer.CommandArgs;
+import org.apache.geronimo.cli.deployer.DistributeCommandArgs;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
 
@@ -37,25 +39,6 @@
  * @version $Rev$ $Date$
  */
 public class CommandDistribute extends AbstractCommand {
-    public CommandDistribute() {
-        super("distribute", "2. Other Commands", "[--inPlace] [--targets target;target;...] [module] [plan]",
-                "Processes a module and adds it to the server environment, but does "+
-                "not start it or mark it to be started in the future. " +
-                "Normally both a module and plan are passed to the deployer.  " +
-                "Sometimes the module contains a plan, or requires no plan, in which case " +
-                "the plan may be omitted.  Sometimes the plan references a module already " +
-                "deployed in the Geronimo server environment, in which case a module does " +
-                "not need to be provided.\n" +
-                "If no targets are provided, the module is distributed to all available " +
-                "targets.  Geronimo only provides one target (ever), so this is primarily " +
-                "useful when using a different driver.\n" +
-                "If inPlace is provided, the module is not copied to the configuration " +
-                "store of the selected targets. The targets directly use the module.");
-    }
-
-    protected CommandDistribute(String command, String group, String helpArgumentList, String helpText) {
-        super(command, group, helpArgumentList, helpText);
-    }
 
     protected ProgressObject runCommand(DeploymentManager mgr, PrintWriter out, boolean inPlace, Target[] tlist, File module, File plan) throws DeploymentException {
         if (inPlace) {
@@ -80,19 +63,18 @@
         return "Distributed";
     }
 
-    public void execute(PrintWriter out, ServerConnection connection, String[] args) throws DeploymentException {
-        if(args.length == 0) {
-            throw new DeploymentSyntaxException("Must specify a module or plan (or both)");
+    public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
+        if (!(commandArgs instanceof DistributeCommandArgs)) {
+            throw new DeploymentSyntaxException("CommandArgs has the type [" + commandArgs.getClass() + "]; expected [" + DistributeCommandArgs.class + "]");
         }
+        DistributeCommandArgs distributeCommandArgs = (DistributeCommandArgs) commandArgs;
         
         BooleanHolder inPlaceHolder = new BooleanHolder();
-        args = processInPlace(args, inPlaceHolder);
+        inPlaceHolder.inPlace = distributeCommandArgs.isInPlace();
         
-        List targets = new ArrayList();
-        args = processTargets(args, targets);
-        if(args.length > 2) {
-            throw new DeploymentSyntaxException("Too many arguments");
-        }
+        List<String> targets = Arrays.asList(distributeCommandArgs.getTargets());
+
+        String[] args = distributeCommandArgs.getArgs();
         File module = null;
         File plan = null;
         if(args.length > 0) {

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java Sat May  5 04:22:39 2007
@@ -18,7 +18,11 @@
 
 import java.io.File;
 import java.io.PrintWriter;
+
 import javax.enterprise.deploy.spi.DeploymentManager;
+
+import org.apache.geronimo.cli.deployer.BaseCommandArgs;
+import org.apache.geronimo.cli.deployer.CommandArgs;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager;
 import org.apache.geronimo.kernel.repository.Artifact;
@@ -30,28 +34,14 @@
  * @version $Rev$ $Date$
  */
 public class CommandInstallCAR extends AbstractCommand {
-    public CommandInstallCAR() {
-        super("install-plugin", "3. Geronimo Plugins", "PluginFile",
-                "Installs a Geronimo plugin you've exported from a Geronimo server " +
-                "or downloaded from an external repository.  The file must be a " +
-                "properly configured Geronimo CAR file.  This is used to add new " +
-                "functionality to the Geronimo server.");
-    }
 
     //todo: provide a way to handle a username and password for the remote repo?
 
-    public CommandInstallCAR(String command, String group, String helpArgumentList, String helpText) {
-        super(command, group, helpArgumentList, helpText);
-    }
-
-    public void execute(PrintWriter out, ServerConnection connection, String[] args) throws DeploymentException {
-        if(args.length == 0) {
-            throw new DeploymentSyntaxException("Must specify Plugin CAR file");
-        }
+    public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
         DeploymentManager dmgr = connection.getDeploymentManager();
         if(dmgr instanceof GeronimoDeploymentManager) {
             GeronimoDeploymentManager mgr = (GeronimoDeploymentManager) dmgr;
-            File carFile = new File(args[0]);
+            File carFile = new File(commandArgs.getArgs()[0]);
             carFile = carFile.getAbsoluteFile();
             if(!carFile.exists() || !carFile.canRead()) {
                 throw new DeploymentException("CAR file cannot be read: "+carFile.getAbsolutePath());
@@ -80,7 +70,7 @@
                 Artifact target = results.getInstalledConfigIDs()[0];
                 System.out.print(DeployUtils.reformat("Now starting "+target+"...", 4, 72));
                 System.out.flush();
-                new CommandStart().execute(out, connection, new String[]{target.toString()});
+                new CommandStart().execute(out, connection, new BaseCommandArgs(new String[]{target.toString()}));
             }
         } else {
             throw new DeploymentException("Cannot install plugins when connected to "+connection.getServerURI());

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java Sat May  5 04:22:39 2007
@@ -26,8 +26,12 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+
 import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.security.auth.login.FailedLoginException;
+
+import org.apache.geronimo.cli.deployer.BaseCommandArgs;
+import org.apache.geronimo.cli.deployer.CommandArgs;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager;
 import org.apache.geronimo.kernel.repository.Artifact;
@@ -41,31 +45,17 @@
  * @version $Rev$ $Date$
  */
 public class CommandListConfigurations extends AbstractCommand {
-    public CommandListConfigurations() {
-        super("search-plugins", "3. Geronimo Plugins", "[MavenRepoURL]",
-                "Lists the Geronimo plugins available in a Maven repository "+
-                "and lets you select a plugin to download and install.  This "+
-                "is used to add new functionality to the Geronimo server.  If " +
-                "no repository is specified the default repositories will be " +
-                "listed to select from, but this means there must have been " +
-                "some default repositories set (by hand or by having the " +
-                "console update to the latest defaults).");
-    }
 
     //todo: provide a way to handle a username and password for the remote repo?
 
-    public CommandListConfigurations(String command, String group, String helpArgumentList, String helpText) {
-        super(command, group, helpArgumentList, helpText);
-    }
-
-    public void execute(PrintWriter out, ServerConnection connection, String[] args) throws DeploymentException {
+    public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
         DeploymentManager dmgr = connection.getDeploymentManager();
         if(dmgr instanceof GeronimoDeploymentManager) {
             GeronimoDeploymentManager mgr = (GeronimoDeploymentManager) dmgr;
             try {
                 String repo = null;
-                if(args.length == 1) {
-                    repo = args[0];
+                if(commandArgs.getArgs().length == 1) {
+                    repo = commandArgs.getArgs()[0];
                 } else {
                     repo = getRepository(out, new BufferedReader(new InputStreamReader(System.in)), mgr);
                 }
@@ -152,7 +142,7 @@
                 if(results.isFinished() && !results.isFailed()) {
                     out.print(DeployUtils.reformat("Now starting "+target.getModuleId()+"...", 4, 72));
                     out.flush();
-                    new CommandStart().execute(out, connection, new String[]{target.getModuleId().toString()});
+                    new CommandStart().execute(out, connection, new BaseCommandArgs(new String[]{target.getModuleId().toString()}));
                 }
             } catch (IOException e) {
                 throw new DeploymentException("Unable to install configuration", e);

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java Sat May  5 04:22:39 2007
@@ -17,15 +17,18 @@
 
 package org.apache.geronimo.deployment.cli;
 
-import org.apache.geronimo.common.DeploymentException;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.List;
 
-import javax.enterprise.deploy.spi.TargetModuleID;
-import javax.enterprise.deploy.spi.Target;
 import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.Target;
+import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.enterprise.deploy.spi.exceptions.TargetException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
+
+import org.apache.geronimo.cli.deployer.CommandArgs;
+import org.apache.geronimo.cli.deployer.ListModulesCommandArgs;
+import org.apache.geronimo.common.DeploymentException;
 
 /**
  * The CLI deployer logic to list modules.
@@ -33,42 +36,22 @@
  * @version $Rev$ $Date$
  */
 public class CommandListModules extends AbstractCommand {
-    public CommandListModules() {
-        super("list-modules", "2. Other Commands", "[--all|--started|--stopped] [target*]",
-                "Lists the modules available on the specified targets.  If " +
-                "--started or --stopped is specified, only started or stopped modules will " +
-                "be listed; otherwise all modules will be listed.  If no targets are " +
-                "specified, then modules on all targets will be listed; otherwise only " +
-                "modules on the specified targets.");
-    }
 
-    public void execute(PrintWriter out, ServerConnection connection, String[] args) throws DeploymentException {
-        List targets = new ArrayList();
+    public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
+        if (!(commandArgs instanceof ListModulesCommandArgs)) {
+            throw new DeploymentSyntaxException("CommandArgs has the type [" + commandArgs.getClass() + "]; expected [" + ListModulesCommandArgs.class + "]");
+        }
+        ListModulesCommandArgs listModulesCommandArgs = (ListModulesCommandArgs) commandArgs;
+
         Boolean started = null;
-        for (int i = 0; i < args.length; i++) {
-            String arg = args[i];
-            if(arg.startsWith("--")) {
-                if(arg.equals("--all")) {
-                    if(started != null) {
-                        throw new DeploymentSyntaxException("Cannot specify more than one of --all, --started, --stopped");
-                    }
-                } else if(arg.equals("--started")) {
-                    if(started != null) {
-                        throw new DeploymentSyntaxException("Cannot specify more than one of --all, --started, --stopped");
-                    }
-                    started = Boolean.TRUE;
-                } else if(arg.equals("--stopped")) {
-                    if(started != null) {
-                        throw new DeploymentSyntaxException("Cannot specify more than one of --all, --started, --stopped");
-                    }
-                    started = Boolean.FALSE;
-                } else {
-                    throw new DeploymentSyntaxException("Unrecognized option '"+arg+"'");
-                }
-            } else {
-                targets.add(arg);
-            }
+        if (listModulesCommandArgs.isStarted()) {
+            started = Boolean.TRUE;
+        } else if (listModulesCommandArgs.isStopped()) {
+            started = Boolean.FALSE;
         }
+        
+        List targets = Arrays.asList(listModulesCommandArgs.getArgs());
+
         final DeploymentManager mgr = connection.getDeploymentManager();
         TargetModuleID[] running = null, notrunning = null;
         Target[] tlist = identifyTargets(targets, mgr);

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListTargets.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListTargets.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListTargets.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListTargets.java Sat May  5 04:22:39 2007
@@ -17,10 +17,12 @@
 
 package org.apache.geronimo.deployment.cli;
 
-import org.apache.geronimo.common.DeploymentException;
+import java.io.PrintWriter;
 
 import javax.enterprise.deploy.spi.Target;
-import java.io.PrintWriter;
+
+import org.apache.geronimo.cli.deployer.CommandArgs;
+import org.apache.geronimo.common.DeploymentException;
 
 /**
  * The CLI deployer logic to list targets.
@@ -28,14 +30,8 @@
  * @version $Rev$ $Date$
  */
 public class CommandListTargets extends AbstractCommand {
-    public CommandListTargets() {
-        super("list-targets", "2. Other Commands", "",
-                "Lists the targets known to the server you've connected to.\n" +
-                "In the case of Geronimo, each configuration store is a separate " +
-                "target.  Geronimo does not yet support clusters as targets.");
-    }
 
-    public void execute(PrintWriter out, ServerConnection connection, String[] args) throws DeploymentException {
+    public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
         Target[] list = connection.getDeploymentManager().getTargets();
         out.println("Available Targets:");
         for(int i = 0; i < list.length; i++) {

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandLogin.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandLogin.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandLogin.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandLogin.java Sat May  5 04:22:39 2007
@@ -17,47 +17,29 @@
 
 package org.apache.geronimo.deployment.cli;
 
-import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.util.SimpleEncryption;
-
-import java.io.PrintWriter;
-import java.io.File;
-import java.io.InputStream;
-import java.io.FileInputStream;
 import java.io.BufferedInputStream;
-import java.io.OutputStream;
 import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
 import java.util.Properties;
 
+import org.apache.geronimo.cli.deployer.CommandArgs;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.util.SimpleEncryption;
+
 /**
  * The CLI deployer logic to start.
  *
  * @version $Rev$ $Date$
  */
 public class CommandLogin extends AbstractCommand {
-    public CommandLogin() {
-        super("login", "1. Common Commands", "",
-                "Saves the username and password for this connection to the "+
-                "file .geronimo-deployer in the current user's home directory.  " +
-                "Future connections to the same server will try to use this "+
-                "saved authentication information instead of prompting where " +
-                "possible.  This information is saved separately per connection " +
-                "URL, so you can specify --url or --host and/or --port on the command " +
-                "line to save a login to a different server.\n" +
-                "WARNING: while the login information is not saved in " +
-                "clear text, it is not secure either.  If you want to " +
-                "save the authentication securely, you should change the " +
-                ".geronimo-deployer file in your home directory so that nobody " +
-                "else can read or write it.");
-    }
-
-    public CommandLogin(String command, String group, String helpArgumentList, String helpText) {
-        super(command, group, helpArgumentList, helpText);
-    }
 
-    public void execute(PrintWriter out, ServerConnection connection, String[] args) throws DeploymentException {
+    public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
         try {
             File authFile = new File(System.getProperty("user.home"), ".geronimo-deployer");
             if(!authFile.exists()) {

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java Sat May  5 04:22:39 2007
@@ -17,19 +17,21 @@
 
 package org.apache.geronimo.deployment.cli;
 
-import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.kernel.repository.Artifact;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.enterprise.deploy.spi.Target;
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.enterprise.deploy.spi.exceptions.TargetException;
 import javax.enterprise.deploy.spi.status.ProgressObject;
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
+
+import org.apache.geronimo.cli.deployer.CommandArgs;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.kernel.repository.Artifact;
 
 /**
  * The CLI deployer logic to redeploy.
@@ -37,31 +39,11 @@
  * @version $Rev$ $Date$
  */
 public class CommandRedeploy extends AbstractCommand {
-    public CommandRedeploy() {
-        super("redeploy", "1. Common Commands", "[module] [plan] [ModuleID|TargetModuleID+]",
-                "A shortcut to undeploy a module from one or more servers, then " +
-                "deploy a new version.  This is not a smooth cutover -- some client " +
-                "requests may be rejected while the redeploy takes place.\n" +
-                "Normally both a module and plan are passed to the deployer. " +
-                "Sometimes the module contains a plan, or requires no plan, in which case " +
-                "the plan may be omitted.  Sometimes the plan references a module already " +
-                "deployed in the Geronimo server environment, in which case a module does " +
-                "not need to be provided.\n" +
-                "If more than one TargetModuleID is provided, all TargetModuleIDs " +
-                "must refer to the same module (just running on different targets).\n" +
-                "Regardless of whether the old module was running or not, the new " +
-                "module will be started.\n" +
-                "If no ModuleID or TargetModuleID is specified, and you're deploying to "+
-                "Geronimo, the deployer will attempt to guess the correct ModuleID for "+
-                "you based on the module and/or plan you provided.\n"+
-                "Note: To specify a TargetModuleID, use the form TargetName|ModuleName");
-    }
 
-    public void execute(PrintWriter out, ServerConnection connection, String[] args) throws DeploymentException {
+    public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
+        String[] args = commandArgs.getArgs();
         setOut(out);
-        if(args.length == 0) {
-            throw new DeploymentSyntaxException("Must specify a module or plan (or both) and optionally module IDs to replace");
-        }
+
         DeploymentManager mgr = connection.getDeploymentManager();
         Target[] allTargets = mgr.getTargets();
         TargetModuleID[] allModules;
@@ -70,6 +52,7 @@
         } catch(TargetException e) {
             throw new DeploymentException("Unable to load modules from server", e);
         }
+        
         List modules = new ArrayList();
         File module = null;
         File plan = null;

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRestart.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRestart.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRestart.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRestart.java Sat May  5 04:22:39 2007
@@ -16,22 +16,16 @@
  */
 package org.apache.geronimo.deployment.cli;
 
-import javax.enterprise.deploy.spi.status.ProgressObject;
+import java.io.PrintWriter;
+
 import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.enterprise.deploy.spi.TargetModuleID;
-import java.io.PrintWriter;
+import javax.enterprise.deploy.spi.status.ProgressObject;
 
 /**
  * The CLI deployer logic to restart.
  */
 public class CommandRestart extends CommandStart {
-    public CommandRestart() {
-        super("restart", "1. Common Commands", "[ModuleID|TargetModuleID]+",
-                "Accepts the configId of a module, or the fully-qualified " +
-                "TargetModuleID identifying both the module and the server or cluster it's " +
-                "on, and restarts that module.  The module should be available to the server " +
-                "and running. If multiple modules are specified, they will all be restarted.\n");
-    }
 
     protected ProgressObject runCommand(PrintWriter out, DeploymentManager mgr, TargetModuleID[] ids) {
         ProgressObject po = mgr.stop(ids);

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java Sat May  5 04:22:39 2007
@@ -17,16 +17,18 @@
 
 package org.apache.geronimo.deployment.cli;
 
-import org.apache.geronimo.common.DeploymentException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.enterprise.deploy.spi.Target;
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.enterprise.deploy.spi.exceptions.TargetException;
 import javax.enterprise.deploy.spi.status.ProgressObject;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
+
+import org.apache.geronimo.cli.deployer.CommandArgs;
+import org.apache.geronimo.common.DeploymentException;
 
 /**
  * The CLI deployer logic to start.
@@ -34,25 +36,10 @@
  * @version $Rev$ $Date$
  */
 public class CommandStart extends AbstractCommand {
-    public CommandStart() {
-        super("start", "1. Common Commands", "[ModuleID|TargetModuleID]+",
-                "Accepts the configId of a module, or the fully-qualified " +
-                "TargetModuleID identifying both the module and the server or cluster it's " +
-                "on, and starts that module.  The module should be available to the server " +
-                "but not currently running.  If multiple modules are specified, they will " +
-                "all be started.\n" +
-                "If the server is not running, the module will be marked to start " +
-                "next time the server is started.");
-    }
-
-    public CommandStart(String command, String group, String helpArgumentList, String helpText) {
-        super(command, group, helpArgumentList, helpText);
-    }
 
-    public void execute(PrintWriter out, ServerConnection connection, String[] args) throws DeploymentException {
-        if(args.length == 0) {
-            throw new DeploymentSyntaxException("Must specify at least one module name or TargetModuleID");
-        }
+    public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
+        String[] args = commandArgs.getArgs();
+        
         DeploymentManager mgr = connection.getDeploymentManager();
         Target[] allTargets = mgr.getTargets();
         TargetModuleID[] allModules;

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStop.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStop.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStop.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStop.java Sat May  5 04:22:39 2007
@@ -17,11 +17,10 @@
 
 package org.apache.geronimo.deployment.cli;
 
-import org.apache.geronimo.common.DeploymentException;
-
 import java.io.PrintWriter;
-import javax.enterprise.deploy.spi.TargetModuleID;
+
 import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.enterprise.deploy.spi.status.ProgressObject;
 
 /**
@@ -30,17 +29,6 @@
  * @version $Rev$ $Date$
  */
 public class CommandStop extends CommandStart {
-    public CommandStop() {
-        super("stop", "1. Common Commands", "[ModuleID|TargetModuleID]+",
-                "Accepts the configId of a module, or the fully-qualified " +
-                "TargetModuleID identifying both the module and the server or cluster it's " +
-                "on, and stops that module.  The module should be available to the server " +
-                "and running.  After stop is completed, the server still has the module and " +
-                "deployment information available, it's just not running.  If multiple " +
-                "modules are specified, they will all be stopped.\n" +
-                "If the server is not running, the module will be marked to not " +
-                "start next time the server is started.");
-    }
 
     protected ProgressObject runCommand(PrintWriter out, DeploymentManager mgr, TargetModuleID[] ids) {
         ProgressObject po = mgr.stop(ids);

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java Sat May  5 04:22:39 2007
@@ -18,8 +18,9 @@
 package org.apache.geronimo.deployment.cli;
 
 import java.io.PrintWriter;
-import javax.enterprise.deploy.spi.TargetModuleID;
+
 import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.enterprise.deploy.spi.status.ProgressObject;
 
 /**
@@ -28,14 +29,6 @@
  * @version $Rev$ $Date$
  */
 public class CommandUndeploy extends CommandStart {
-    public CommandUndeploy() {
-        super("undeploy", "1. Common Commands", "[ModuleID|TargetModuleID]+",
-                "Accepts the configId of a module, or the fully-qualified " +
-                "TargetModuleID identifying both the module and the server or cluster it's " +
-                "on, stops that module, and removes the deployment files for that module " +
-                "from the server environment.  If multiple modules are specified, they will " +
-                "all be undeployed.");
-    }
 
     protected ProgressObject runCommand(PrintWriter out, DeploymentManager mgr, TargetModuleID[] ids) {
         ProgressObject po = mgr.undeploy(ids);

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployCommand.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployCommand.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployCommand.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployCommand.java Sat May  5 04:22:39 2007
@@ -17,21 +17,18 @@
 
 package org.apache.geronimo.deployment.cli;
 
+import org.apache.geronimo.cli.deployer.CommandArgs;
 import org.apache.geronimo.common.DeploymentException;
 
 import java.io.PrintWriter;
 
 /**
- * An abstraction of various CLI deployer commands.  Holds metadata like help
- * text, and also the logic to validate arguments and execute the command.
+ * An abstraction of various CLI deployer commands.
  *
  * @version $Rev$ $Date$
  */
 public interface DeployCommand {
-    String getCommandGroup();
-    String getCommandName();
-    String getHelpArgumentList();
-    String getHelpText();
     boolean isLocalOnly();
-    void execute(PrintWriter out, ServerConnection connection, String[] args) throws DeploymentException;
+
+    void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException;
 }

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java Sat May  5 04:22:39 2007
@@ -24,19 +24,30 @@
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
-import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
+import java.util.IdentityHashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
 
 import javax.enterprise.deploy.spi.factories.DeploymentFactory;
 
+import org.apache.geronimo.cli.deployer.CommandArgs;
+import org.apache.geronimo.cli.deployer.CommandFileCommandMetaData;
+import org.apache.geronimo.cli.deployer.CommandMetaData;
+import org.apache.geronimo.cli.deployer.DeployCommandMetaData;
+import org.apache.geronimo.cli.deployer.DeployerCLParser;
+import org.apache.geronimo.cli.deployer.DistributeCommandMetaData;
+import org.apache.geronimo.cli.deployer.InstallPluginCommandMetaData;
+import org.apache.geronimo.cli.deployer.ListModulesCommandMetaData;
+import org.apache.geronimo.cli.deployer.ListTargetsCommandMetaData;
+import org.apache.geronimo.cli.deployer.LoginCommandMetaData;
+import org.apache.geronimo.cli.deployer.RedeployCommandMetaData;
+import org.apache.geronimo.cli.deployer.RestartCommandMetaData;
+import org.apache.geronimo.cli.deployer.SearchPluginsCommandMetaData;
+import org.apache.geronimo.cli.deployer.StartCommandMetaData;
+import org.apache.geronimo.cli.deployer.StopCommandMetaData;
+import org.apache.geronimo.cli.deployer.UndeployCommandMetaData;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
@@ -58,21 +69,21 @@
  */
 public class DeployTool implements Main {
 
-    private static final Collection<DeployCommand> commands = new ArrayList<DeployCommand>();
+    private static final IdentityHashMap<CommandMetaData, DeployCommand> commands = new IdentityHashMap<CommandMetaData, DeployCommand>();
 
     static {
-        commands.add(new CommandLogin());
-        commands.add(new CommandDeploy());
-        commands.add(new CommandDistribute());
-        commands.add(new CommandListModules());
-        commands.add(new CommandListTargets());
-        commands.add(new CommandRedeploy());
-        commands.add(new CommandStart());
-        commands.add(new CommandStop());
-        commands.add(new CommandRestart());
-        commands.add(new CommandUndeploy());
-        commands.add(new CommandListConfigurations());
-        commands.add(new CommandInstallCAR());
+        commands.put(LoginCommandMetaData.META_DATA, new CommandLogin());
+        commands.put(DeployCommandMetaData.META_DATA, new CommandDeploy());
+        commands.put(DistributeCommandMetaData.META_DATA, new CommandDistribute());
+        commands.put(ListModulesCommandMetaData.META_DATA, new CommandListModules());
+        commands.put(ListTargetsCommandMetaData.META_DATA, new CommandListTargets());
+        commands.put(RedeployCommandMetaData.META_DATA, new CommandRedeploy());
+        commands.put(StartCommandMetaData.META_DATA, new CommandStart());
+        commands.put(StopCommandMetaData.META_DATA, new CommandStop());
+        commands.put(RestartCommandMetaData.META_DATA, new CommandRestart());
+        commands.put(UndeployCommandMetaData.META_DATA, new CommandUndeploy());
+        commands.put(SearchPluginsCommandMetaData.META_DATA, new CommandListConfigurations());
+        commands.put(InstallPluginCommandMetaData.META_DATA, new CommandInstallCAR());
     }
 
     private boolean failed = false;
@@ -92,77 +103,59 @@
         this.deploymentFactory = deploymentFactory;
     }
     
-    public int execute(String args[]) {
+    public int execute(Object opaque) {
+        if (! (opaque instanceof DeployerCLParser)) {
+            throw new IllegalArgumentException("Argument type is [" + opaque.getClass() + "]; expected [" + DeployerCLParser.class + "]");
+        }
+        DeployerCLParser parser = (DeployerCLParser) opaque;
+        
         PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out), true);
         InputStream in = System.in;
 
-        String command;
-        String[] commandArgs = new String[0];
-        if(args.length == 0) {
-            command = "help";
-        } else {
-            String[] temp = getCommonArgsAndCommand(args);
-            if(temp == null || temp.length == 0) {
-                command = "help";
-            } else {
-                command = temp[temp.length-1];
-                if(generalArgs.length == 0 && temp.length > 1) {
-                    generalArgs = new String[temp.length-1];
-                    System.arraycopy(temp, 0, generalArgs, 0, temp.length-1);
-                }
-                commandArgs = new String[args.length - temp.length];
-                System.arraycopy(args, temp.length, commandArgs, 0, commandArgs.length);
-            }
-        }
-        if(command.equals("help")) {
-            showHelp(out, commandArgs);
-        } else if(command.equals("command-file")) {
+        CommandMetaData commandMetaData = parser.getCommandMetaData();
+        CommandArgs commandArgs = parser.getCommandArgs();
+        if(commandMetaData == CommandFileCommandMetaData.META_DATA) {
             multipleCommands = true;
-            if(commandArgs.length != 1) {
-                processException(out, new DeploymentSyntaxException("Must provide a command file to read from and no other arguments"));
+            String arg = commandArgs.getArgs()[0];
+            File source = new File(arg);
+            if(!source.exists() || !source.canRead() || source.isDirectory()) {
+                processException(out, new DeploymentSyntaxException("Cannot read command file "+source.getAbsolutePath()));
             } else {
-                String arg = commandArgs[0];
-                File source = new File(arg);
-                if(!source.exists() || !source.canRead() || source.isDirectory()) {
-                    processException(out, new DeploymentSyntaxException("Cannot read command file "+source.getAbsolutePath()));
-                } else {
-                    try {
-                        BufferedReader commands = new BufferedReader(new FileReader(source));
-                        String line;
-                        boolean oneFailed = false;
-                        while((line = commands.readLine()) != null) {
-                            line = line.trim();
-                            if(!line.equals("")) {
-                                String[] lineArgs = splitCommand(line);
-                                if(failed) {
-                                    oneFailed = true;
-                                }
-                                failed = false;
-                                execute(lineArgs);
+                try {
+                    BufferedReader commands = new BufferedReader(new FileReader(source));
+                    String line;
+                    boolean oneFailed = false;
+                    while((line = commands.readLine()) != null) {
+                        line = line.trim();
+                        if(!line.equals("")) {
+                            String[] lineArgs = splitCommand(line);
+                            if(failed) {
+                                oneFailed = true;
                             }
-                        }
-                        failed = oneFailed;
-                    } catch (IOException e) {
-                        processException(out, new DeploymentException("Unable to read command file", e));
-                    } finally {
-                        try {
-                            con.close();
-                        } catch (DeploymentException e) {
-                            processException(out, e);
+                            failed = false;
+                            execute(lineArgs);
                         }
                     }
+                    failed = oneFailed;
+                } catch (IOException e) {
+                    processException(out, new DeploymentException("Unable to read command file", e));
+                } finally {
+                    try {
+                        con.close();
+                    } catch (DeploymentException e) {
+                        processException(out, e);
+                    }
                 }
             }
         } else {
-            DeployCommand dc = getCommand(command);
+            DeployCommand dc = commands.get(commandMetaData);
             if(dc == null) {
                 out.println();
-                processException(out, new DeploymentSyntaxException("No such command: '"+command+"'"));
-                showHelp(out, new String[0]);
+                processException(out, new DeploymentSyntaxException("No such command: '"+commandMetaData+"'"));
             } else {
                 try {
                     if(con == null) {
-                        con = new ServerConnection(generalArgs, out, in, kernel, deploymentFactory);
+                        con = new ServerConnection(parser, out, in, kernel, deploymentFactory);
                     }
                     try {
                         dc.execute(out, con, commandArgs);
@@ -217,127 +210,6 @@
         }
     }
 
-    private void showHelp(PrintWriter out, String[] args) {
-        out.println();
-        out.println("Command-line deployer syntax:");
-        out.println("    deployer [general options] command [command options]");
-        out.println();
-        if(args.length > 0) {
-            DeployCommand command = getCommand(args[0]);
-            if(command != null) {
-                out.println("Help for command: "+command.getCommandName());
-                out.println();
-                out.println("    deployer "+hangingIndent(command.getCommandName()+" "+command.getHelpArgumentList(), 13));
-                out.println();
-                out.print(DeployUtils.reformat(command.getHelpText(), 8, 72));
-                out.println();
-                return;
-            } else if(args[0].equals("options")) {
-                out.println("Help on general options:");
-                out.println();
-                Map map = ServerConnection.getOptionHelp();
-                for (Iterator it = map.keySet().iterator(); it.hasNext();) {
-                    String s = (String) it.next();
-                    out.println("   "+s);
-                    out.println();
-                    out.print(DeployUtils.reformat((String)map.get(s), 8, 72));
-                }
-                return;
-            } else if(args[0].equals("all")) {
-                DeployCommand[] all = getAllCommands();
-                out.println();
-                out.println("All commands");
-                out.println();
-                for (int i = 0; i < all.length; i++) {
-                    DeployCommand cmd = all[i];
-                    out.println("    deployer "+hangingIndent(cmd.getCommandName()+" "+cmd.getHelpArgumentList(), 13));
-                    out.print(DeployUtils.reformat(cmd.getHelpText(), 8, 72));
-                }
-                out.println();
-                return;
-            }
-        }
-        out.println("The general options are:");
-        Map map = ServerConnection.getOptionHelp();
-        for (Iterator it = map.keySet().iterator(); it.hasNext();) {
-            String s = (String) it.next();
-            out.println("    "+s);
-        }
-        out.println();
-        out.println("The available commands are:");
-        renderCommandList(out, getAllCommands());
-        out.println();
-        out.println("For more information about a specific command, run");
-        out.println("    deployer help [command name]");
-        out.println();
-        out.println("For more information about general options, run");
-        out.println("    deployer help options");
-        out.println();
-    }
-
-    private String hangingIndent(String source, int cols) {
-        String s = DeployUtils.reformat(source, cols, 72);
-        return s.substring(cols);
-    }
-
-    private void renderCommandList(PrintWriter out, DeployCommand[] all) {
-        Map temp = new HashMap();
-        for (int i = 0; i < all.length; i++) {
-            DeployCommand command = all[i];
-            List list = (List) temp.get(command.getCommandGroup());
-            if(list == null) {
-                list = new ArrayList();
-                temp.put(command.getCommandGroup(), list);
-            }
-            list.add(command.getCommandName());
-        }
-        List groups = new ArrayList(temp.keySet());
-        Collections.sort(groups);
-        for (int i = 0; i < groups.size(); i++) {
-            String name = (String) groups.get(i);
-            out.println("    "+name);
-            List list = (List) temp.get(name);
-            Collections.sort(list);
-            for (int j = 0; j < list.size(); j++) {
-                String cmd = (String) list.get(j);
-                out.println("        "+cmd);
-            }
-        }
-    }
-
-    private String[] getCommonArgsAndCommand(String[] all) {
-        List list = new ArrayList();
-        for (int i = 0; i < all.length; i++) {
-            String s = all[i];
-            boolean option = ServerConnection.isGeneralOption(list, s);
-            list.add(s);
-            if(!option) {
-                break;
-            }
-        }
-        return (String[]) list.toArray(new String[list.size()]);
-    }
-
-    private DeployCommand getCommand(String commandName) {
-        for (DeployCommand command : commands) {
-            if (command.getCommandName().equals(commandName)) {
-                return command;
-            }
-        }
-        return null;
-    }
-
-    private DeployCommand[] getAllCommands() {
-        DeployCommand[] list = (DeployCommand[]) commands.toArray(new DeployCommand[0]);
-        Arrays.sort(list, new Comparator() {
-            public int compare(Object o1, Object o2) {
-                return ((DeployCommand)o1).getCommandName().compareTo(((DeployCommand)o2).getCommandName());
-            }
-        });
-        return list;
-    }
-    
-    
     public static final GBeanInfo GBEAN_INFO;
     public static final String GBEAN_REF_DEPLOYMENT_FACTORY = "DeploymentFactory";
     

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java Sat May  5 04:22:39 2007
@@ -20,13 +20,8 @@
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.StringReader;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import javax.enterprise.deploy.spi.TargetModuleID;
-import org.apache.geronimo.common.DeploymentException;
+
 import org.apache.geronimo.deployment.plugin.ConfigIDExtractor;
-import org.apache.geronimo.kernel.repository.Artifact;
 
 /**
  * Various helpers for deployment.

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java Sat May  5 04:22:39 2007
@@ -25,9 +25,6 @@
 import java.io.InputStream;
 import java.io.PrintWriter;
 import java.io.Serializable;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 import java.util.jar.JarFile;
 
@@ -36,6 +33,7 @@
 import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
 import javax.enterprise.deploy.spi.factories.DeploymentFactory;
 
+import org.apache.geronimo.cli.deployer.DeployerCLParser;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.plugin.factories.AuthenticationFailedException;
 import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
@@ -50,55 +48,6 @@
  * @version $Rev$ $Date$
  */
 public class ServerConnection {
-    private final static Map OPTION_HELP = new LinkedHashMap(9);
-
-    static {
-        OPTION_HELP.put("--uri", "A URI to contact the server.  If not specified, the deployer defaults to " +
-                "operating on a Geronimo server running on the standard port on localhost.\n" +
-                "A URI to connect to Geronimo (including optional host and port parameters) has the form: " +
-                "deployer:geronimo:jmx[://host[:port]] (though you could also just use --host and --port instead).");
-        OPTION_HELP.put("--host", "The host name of a Geronimo server to deploy to.  This option is " +
-                "not compatible with --uri, but is often used with --port.");
-        OPTION_HELP.put("--port", "The RMI listen port of a Geronimo server to deploy to.  This option is " +
-                "not compatible with --uri, but is often used with --host.  The default port is 1099.");
-        OPTION_HELP.put("--driver", "If you want to use this tool with a server other than Geronimo, " +
-                "then you must provide the path to its driver JAR.  Currently, manifest " +
-                "Class-Path entries in that JAR are ignored.");
-        OPTION_HELP.put("--user", "If the deployment operation requires authentication, then you can " +
-                "specify the username to use to connect.  If no password is specified, the " +
-                "deployer will attempt to connect to the server with no password, and if " +
-                "that fails, will prompt you for a password.");
-        OPTION_HELP.put("--password", "Specifies a password to use to authenticate to the server.");
-        OPTION_HELP.put("--syserr", "Enables error logging to syserr.  Disabled by default.");
-        OPTION_HELP.put("--verbose", "Enables verbose execution mode.  Disabled by default.");
-        OPTION_HELP.put("--offline", "Deploy offline to a local server, using whatever deployers are available in the local server");
-    }
-
-    public static Map getOptionHelp() {
-        return OPTION_HELP;
-    }
-
-    /**
-     * Checks whether the stated command-line argument is a general argument (which
-     * may be the general argument itself, or a required parameter after the general
-     * argument).  For example, if the arguments were "--user bob foo" then
-     * this should return true for "--user" and "bob" and false for "foo".
-     *
-     * @param args   The previous arguments on the command line
-     * @param option The argument we're checking at the moment
-     * @return True if the argument we're checking is part of a general argument
-     */
-    public static boolean isGeneralOption(List args, String option) {
-        if (OPTION_HELP.containsKey(option) || option.equals("--url")) {
-            return true;
-        }
-        if (args.size() == 0) {
-            return false;
-        }
-        String last = (String) args.get(args.size() - 1);
-        return last.equals("--uri") || last.equals("--url") || last.equals("--driver") || last.equals("--user") ||
-                last.equals("--password") || last.equals("--host") || last.equals("--port");
-    }
 
     private final static String DEFAULT_URI = "deployer:geronimo:jmx";
 
@@ -111,85 +60,26 @@
     private boolean logToSysErr;
     private boolean verboseMessages;
 
-    public ServerConnection(String[] args, PrintWriter out, InputStream in, Kernel kernel, DeploymentFactory geronimoDeploymentFactory) throws DeploymentException {
+    public ServerConnection(DeployerCLParser parser, PrintWriter out, InputStream in, Kernel kernel, DeploymentFactory geronimoDeploymentFactory) throws DeploymentException {
         if (null == kernel) {
             throw new IllegalArgumentException("kernel is required");
         }
         this.geronimoDeploymentFactory = geronimoDeploymentFactory;
 
-        String uri = null, driver = null, user = null, password = null, host = null;
-        Integer port = null;
         this.out = out;
         this.in = in;
         boolean offline = false;
-        for (int i = 0; i < args.length; i++) {
-            String arg = args[i];
-            if (arg.equals("--uri") || arg.equals("--url")) {
-                if (uri != null) {
-                    throw new DeploymentSyntaxException("Cannot specify more than one URI");
-                } else if (i >= args.length - 1) {
-                    throw new DeploymentSyntaxException("Must specify a URI (e.g. --uri deployer:...)");
-                }
-                if (host != null || port != null) {
-                    throw new DeploymentSyntaxException("Cannot specify a URI as well as a host/port");
-                }
-                uri = args[++i];
-            } else if (arg.equals("--host")) {
-                if (host != null) {
-                    throw new DeploymentSyntaxException("Cannot specify more than one host");
-                } else if (i >= args.length - 1) {
-                    throw new DeploymentSyntaxException("Must specify a hostname (e.g. --host localhost)");
-                }
-                if (uri != null) {
-                    throw new DeploymentSyntaxException("Cannot specify a URI as well as a host/port");
-                }
-                host = args[++i];
-            } else if (arg.equals("--port")) {
-                if (port != null) {
-                    throw new DeploymentSyntaxException("Cannot specify more than one port");
-                } else if (i >= args.length - 1) {
-                    throw new DeploymentSyntaxException("Must specify a port (e.g. --port 1099)");
-                }
-                if (uri != null) {
-                    throw new DeploymentSyntaxException("Cannot specify a URI as well as a host/port");
-                }
-                try {
-                    port = new Integer(args[++i]);
-                } catch (NumberFormatException e) {
-                    throw new DeploymentSyntaxException("Port must be a number (" + e.getMessage() + ")");
-                }
-            } else if (arg.equals("--driver")) {
-                if (driver != null) {
-                    throw new DeploymentSyntaxException("Cannot specify more than one driver");
-                } else if (i >= args.length - 1) {
-                    throw new DeploymentSyntaxException("Must specify a driver JAR (--driver jarfile)");
-                }
-                driver = args[++i];
-            } else if (arg.equals("--offline")) {
-                //throw new DeploymentSyntaxException("This tool no longer handles offline deployment");
-                offline = true;
-            } else if (arg.equals("--user")) {
-                if (user != null) {
-                    throw new DeploymentSyntaxException("Cannot specify more than one user name");
-                } else if (i >= args.length - 1) {
-                    throw new DeploymentSyntaxException("Must specify a username (--user username)");
-                }
-                user = args[++i];
-            } else if (arg.equals("--password")) {
-                if (password != null) {
-                    throw new DeploymentSyntaxException("Cannot specify more than one password");
-                } else if (i >= args.length - 1) {
-                    throw new DeploymentSyntaxException("Must specify a password (--password password)");
-                }
-                password = args[++i];
-            } else if (arg.equals("--verbose")) {
-                verboseMessages = true;
-            } else if (arg.equals("--syserr")) {
-                logToSysErr = true;
-            } else {
-                throw new DeploymentException("Invalid option " + arg);
-            }
-        }
+        
+        String uri = parser.getURI();
+        String driver = parser.getDriver();
+        String user = parser.getUser();
+        String password = parser.getPassword();
+        String host = parser.getHost();
+        Integer port = parser.getPort();
+        verboseMessages = parser.isVerbose();
+        logToSysErr = parser.isSyserr();
+        offline = parser.isOffline();
+
         if ((driver != null) && uri == null) {
             throw new DeploymentSyntaxException("A custom driver requires a custom URI");
         }

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java Sat May  5 04:22:39 2007
@@ -54,9 +54,12 @@
 		StopServer cmd = new StopServer();
 		cmd.execute(args);
 	}
-
-	public int execute(String args[]) {
-        this.args = args;
+    
+    public int execute(Object opaque) {
+        if (! (opaque instanceof String[])) {
+            throw new IllegalArgumentException("Argument type is [" + opaque.getClass() + "]; expected [" + String[].class + "]");
+        }
+        this.args = (String[]) opaque;
 
         int i = 0;
         while (i < args.length && args[i].startsWith("--")) {

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/Main.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/Main.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/Main.java (original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/Main.java Sat May  5 04:22:39 2007
@@ -22,5 +22,5 @@
  * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
  */
 public interface Main {
-    int execute(String[] args);
+    int execute(Object opaque);
 }

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainBootstrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainBootstrapper.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainBootstrapper.java (original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainBootstrapper.java Sat May  5 04:22:39 2007
@@ -35,7 +35,8 @@
 public class MainBootstrapper extends MainConfigurationBootstrapper {
 
     public static void main(String[] args) {
-        main(new MainBootstrapper(), args);
+        int status = main(new MainBootstrapper(), args);
+        System.exit(status);
     }
     
     public void loadPersistentConfigurations() throws Exception {

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainConfigurationBootstrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainConfigurationBootstrapper.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainConfigurationBootstrapper.java (original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainConfigurationBootstrapper.java Sat May  5 04:22:39 2007
@@ -22,53 +22,19 @@
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelFactory;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
-import org.apache.geronimo.kernel.log.GeronimoLogging;
 
 /**
  *
  * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
  */
 public class MainConfigurationBootstrapper {
-    public final static String ARGUMENT_VERBOSE_SHORTFORM = "-v";
-    public final static String ARGUMENT_VERBOSE = "--verbose";
-    public final static String ARGUMENT_MORE_VERBOSE_SHORTFORM = "-vv";
-    public final static String ARGUMENT_MORE_VERBOSE = "--veryverbose";
-
-    public static String getVerboseLevel(String[] args) {
-        String verboseArg = null;
-        for (int i = 0; i < args.length; i++) {
-            verboseArg = filterVerboseArgument(args[i]);
-            if (null != verboseArg) {
-                break;
-            }
-        }
-        return verboseArg;
-    }
-
-    public static String filterVerboseArgument(String arg) {
-        if (arg.equals(ARGUMENT_VERBOSE_SHORTFORM) || arg.equals(ARGUMENT_VERBOSE)) {
-            return ARGUMENT_VERBOSE;
-        } else if (arg.equals(ARGUMENT_MORE_VERBOSE_SHORTFORM) || arg.equals(ARGUMENT_MORE_VERBOSE)) {
-            return ARGUMENT_MORE_VERBOSE;
-        }
-        return null;
-    }
-
-    public static boolean isVerboseLevel(String verboseLevel) {
-        return verboseLevel.equals(ARGUMENT_VERBOSE);
-    }
-
-    public static boolean isMoreVerboseLevel(String verboseLevel) {
-        return verboseLevel.equals(ARGUMENT_MORE_VERBOSE);
-    }
 
     public static void main(String[] args) {
-        main(new MainConfigurationBootstrapper(), args);
+        int status = main(new MainConfigurationBootstrapper(), args);
+        System.exit(status);
     }
 
-    public static void main(MainConfigurationBootstrapper bootstrapper, String[] args) {
-        bootstrapper.initializeLogging(args);
-        
+    public static int main(MainConfigurationBootstrapper bootstrapper, Object opaque) {
         Main main = bootstrapper.getMain(MainConfigurationBootstrapper.class.getClassLoader());
 
         int exitCode;
@@ -76,11 +42,11 @@
         try {
             ClassLoader newTCCL = main.getClass().getClassLoader();
             Thread.currentThread().setContextClassLoader(newTCCL);
-            exitCode = main.execute(args);
+            exitCode = main.execute(opaque);
         } finally {
             Thread.currentThread().setContextClassLoader(oldTCCL);
         }
-        System.exit(exitCode);
+        return exitCode;
     }
 
     protected Kernel kernel;
@@ -136,26 +102,6 @@
 
     public Kernel getKernel() {
         return kernel;
-    }
-    
-    protected void initializeLogging(String[] args) {
-        String verboseArg = getVerboseLevel(args);
-        
-        //
-        // FIXME: Allow -v -> INFO, -vv -> DEBUG, -vvv -> TRACE
-        //
-        
-        // This MUST be done before the first log is acquired (which the startup monitor below does)
-        // Generally we want to suppress anything but WARN until the log GBean starts up
-        GeronimoLogging level = GeronimoLogging.WARN;
-        if (verboseArg != null) {
-            if (isVerboseLevel(verboseArg)) {
-                level = GeronimoLogging.DEBUG;
-            } else if (isMoreVerboseLevel(verboseArg)) {
-                level = GeronimoLogging.TRACE;
-            }
-        }
-        GeronimoLogging.initialize(level);
     }
     
 }

Modified: geronimo/server/trunk/modules/geronimo-system/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/pom.xml?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-system/pom.xml Sat May  5 04:22:39 2007
@@ -35,6 +35,12 @@
     <dependencies>
         <dependency>
             <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-cli</artifactId>
+            <version>${version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
             <artifactId>geronimo-common</artifactId>
             <version>${version}</version>
         </dependency>

Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/ClientCommandLine.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/ClientCommandLine.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/ClientCommandLine.java (original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/ClientCommandLine.java Sat May  5 04:22:39 2007
@@ -18,6 +18,8 @@
 
 import java.util.Collections;
 
+import org.apache.geronimo.cli.CLParserException;
+import org.apache.geronimo.cli.client.ClientCLParser;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.kernel.Jsr77Naming;
@@ -27,28 +29,26 @@
  * @version $Revision$ $Date$
  */
 public class ClientCommandLine extends CommandLine {
+
     /**
      * Command line entry point called by executable jar
      * @param args command line args
      */
     public static void main(String[] args) {
+        ClientCLParser parser = new ClientCLParser(System.out);
+        try {
+            parser.parse(args);
+        } catch (CLParserException e) {
+            System.err.println(e.getMessage());
+            parser.displayHelp();
+            System.exit(1);
+        }
+        
         ClientCommandLine clientCommandLine = new ClientCommandLine();
-        int exitCode = clientCommandLine.execute(args);
+        int exitCode = clientCommandLine.execute(parser);
         System.exit(exitCode);
     }
 
-    private static void showHelp() {
-        System.out.println();
-        System.out.println("syntax:   java -jar bin/client.jar config-name [app arg] [app arg] ...");
-        System.out.println();
-        System.out.println("The first argument should identify the Geronimo configuration that");
-        System.out.println("contains the application client you want to run.");
-        System.out.println();
-        System.out.println("The rest of the arguments will be passed as arguments to the");
-        System.out.println("application client when it is started.");
-        System.out.println();
-    }
-
     public ClientCommandLine(Artifact configuration, String[] args) throws Exception {
         startClient(configuration, args);
     }
@@ -56,22 +56,11 @@
     protected ClientCommandLine() {
     }
     
-    public int execute(String[] args) {
+    public int execute(ClientCLParser parser) {
         log.info("Client startup begun");
-        if(args.length == 0) {
-            System.out.println();
-            System.out.println("ERROR: No arguments");
-            showHelp();
-            return 1;
-        } else if(args[0].equals("--help") || args[0].equals("-h") || args[0].equals("/?")) {
-            showHelp();
-            return 0;
-        }
         try {
-            Artifact configuration = Artifact.create(args[0]);
-            String[] clientArgs = new String[args.length -1];
-            System.arraycopy(args, 1, clientArgs, 0, clientArgs.length);
-            return startClient(configuration, clientArgs);
+            Artifact configuration = Artifact.create(parser.getApplicationClientConfiguration());
+            return startClient(configuration, parser.getApplicationClientArgs());
         } catch (Exception e) {
             ExceptionUtil.trimStackTrace(e);
             e.printStackTrace();

Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/Daemon.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/Daemon.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/Daemon.java (original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/Daemon.java Sat May  5 04:22:39 2007
@@ -20,6 +20,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 
+import org.apache.geronimo.cli.CLParserException;
+import org.apache.geronimo.cli.daemon.DaemonCLParser;
 import org.apache.geronimo.kernel.KernelFactory;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
 
@@ -84,6 +86,14 @@
      * @param args the command line arguments
      */
     public static void main(String[] args) {
-        new Daemon().execute(args);
+        DaemonCLParser parser = new DaemonCLParser(System.out);
+        try {
+            parser.parse(args);
+        } catch (CLParserException e) {
+            System.err.println(e.getMessage());
+            parser.displayHelp();
+            System.exit(1);
+        }
+        new Daemon().execute(parser);
     }
 }

Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/EmbeddedClientCommandLine.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/EmbeddedClientCommandLine.java?view=diff&rev=535507&r1=535506&r2=535507
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/EmbeddedClientCommandLine.java (original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/EmbeddedClientCommandLine.java Sat May  5 04:22:39 2007
@@ -16,6 +16,7 @@
  */
 package org.apache.geronimo.system.main;
 
+import org.apache.geronimo.cli.client.ClientCLParser;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.kernel.Kernel;
@@ -35,6 +36,13 @@
         this.kernel = kernel;
     }
 
+    public int execute(Object opaque) {
+        if (! (opaque instanceof ClientCLParser)) {
+            throw new IllegalArgumentException("Argument type is [" + opaque.getClass() + "]; expected [" + String[].class + "]");
+        }
+        return super.execute((ClientCLParser) opaque);
+    }
+    
     @Override
     protected Kernel getBootedKernel() throws Exception {
         return kernel;



Mime
View raw message