geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r410868 - /geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/HelpCommand.java
Date Thu, 01 Jun 2006 14:29:12 GMT
Author: jdillon
Date: Thu Jun  1 07:29:12 2006
New Revision: 410868

URL: http://svn.apache.org/viewvc?rev=410868&view=rev
Log:
Added crude topic support to help command

Modified:
    geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/HelpCommand.java

Modified: geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/HelpCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/HelpCommand.java?rev=410868&r1=410867&r2=410868&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/HelpCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/HelpCommand.java
Thu Jun  1 07:29:12 2006
@@ -29,7 +29,7 @@
 import org.apache.geronimo.gshell.console.IO;
 
 /**
- * Display command help
+ * Display help
  *
  * @version $Id$
  */
@@ -58,15 +58,30 @@
         CommandLineParser parser = new PosixParser();
         CommandLine line = parser.parse(options, args);
 
-        if (line.hasOption('h')) {
-            io.out.println(getName() + " -- display gshell help");
+        boolean usage = false;
+        String topic = null;
+
+        String[] _args = line.getArgs();
+        if (_args.length > 1) {
+            io.err.println("Too many arguments: " + _args);
+            return Command.FAILURE;
+        }
+        else if (_args.length == 1) {
+            topic = _args[0];
+        }
+        else {
+            usage = true;
+        }
+
+        if (usage || line.hasOption('h')) {
+            io.out.println(getName() + " -- display help");
             io.out.println();
 
             HelpFormatter formatter = new HelpFormatter();
             formatter.printHelp(
                 io.out,
                 80, // width (FIXME: Should pull from gshell.columns variable)
-                getName() + " [options]",
+                getName() + " [options] [topic]",
                 "",
                 options,
                 4, // left pad
@@ -75,22 +90,38 @@
                 false); // auto usage
 
             io.out.println();
+            io.out.println("For a list of topics try: help topics");
+            io.out.println();
 
             return Command.SUCCESS;
         }
 
         //
-        // HACK: Need to DI this guy, but for now this will work
+        // TODO: Reuse our command bits...
         //
-        
-        CommandManager manager = new CommandManager();
 
-        //
-        // HACK: For now just list all know commands
-        //
-
-        for (String name : manager.commandNames()) {
-            io.out.println(name);
+        if (topic.equals("topics")) {
+            io.out.println("Available topics:");
+            io.out.println("  topics");
+            io.out.println("  commands");
+        }
+        if (topic.equals("commands")) {
+            //
+            // HACK: Need to DI this guy, but for now this will work
+            //
+
+            CommandManager manager = new CommandManager();
+
+            io.out.println("Available commands:");
+
+            //
+            // HACK: For now just list all know commands
+            //
+
+            for (String name : manager.commandNames()) {
+                io.out.print("  ");
+                io.out.println(name);
+            }
         }
 
         return Command.SUCCESS;



Mime
View raw message