This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

compilation option patch


Below is a patch that will print out the compilation options as part
of the usage message.

Regards,
Chris Dean


Index: ChangeLog
===================================================================
RCS file: /cvs/kawa/kawa/ChangeLog,v
retrieving revision 1.424
diff -u -w -r1.424 ChangeLog
--- ChangeLog	21 Jul 2004 00:06:10 -0000	1.424
+++ ChangeLog	28 Jul 2004 04:28:25 -0000
@@ -1,3 +1,7 @@
+2004-07-27  Chris Dean  <ctdean@sokitomi.com>
+
+	* kawa/repl.java: Print out compilation options
+
 2004-07-20  Per Bothner  <per@bothner.com>
 
 	* kawa/GuiConsole.java:  Remove unused import statements.
Index: gnu/text/ChangeLog
===================================================================
RCS file: /cvs/kawa/kawa/gnu/text/ChangeLog,v
retrieving revision 1.49
diff -u -w -r1.49 ChangeLog
--- gnu/text/ChangeLog	20 Jul 2004 08:22:29 -0000	1.49
+++ gnu/text/ChangeLog	28 Jul 2004 04:28:25 -0000
@@ -1,3 +1,7 @@
+2004-07-27  Chris Dean  <ctdean@sokitomi.com>
+
+	* Options.java: add keys() function
+
 2004-07-20  Per Bothner  <per@bothner.com>
 
 	* IntegerFormat.java:  Remove useless import statements.
Index: gnu/text/Options.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/text/Options.java,v
retrieving revision 1.3
diff -u -w -r1.3 Options.java
--- gnu/text/Options.java	21 Oct 2003 07:00:25 -0000	1.3
+++ gnu/text/Options.java	28 Jul 2004 04:28:25 -0000
@@ -4,6 +4,7 @@
 package gnu.text;
 import java.util.Hashtable;
 import java.util.Vector;
+import java.util.Enumeration;
 
 /** Mananges a table of named options,
  * Can inherit from another table of "default" options. */
@@ -231,7 +232,43 @@
 	reset(key, oldValue);
       }
   }
+
+  /** Return the list of option keys.
+   */
+  public Vector keys ()
+  {
+    return getKeys(new Vector());
 }
+
+  private Vector getKeys(Vector allKeys)
+  {
+    if (infoTable != null)
+      {
+        Enumeration e = infoTable.keys();
+        while (e.hasMoreElements())
+          {
+            Object k = e.nextElement();
+            if (! allKeys.contains(k))
+              allKeys.add(k);
+          }
+      }
+    
+    if (previous != null)
+      previous.getKeys(allKeys);
+    
+    return allKeys;
+  }
+
+  public String getDoc(String key)
+  {
+    OptionInfo info = getInfo(key);
+    if (key == null)
+      return null;
+    return info.documentation;
+  }
+  
+}
+
 final class OptionInfo
 {
   OptionInfo next;
Index: kawa/repl.java
===================================================================
RCS file: /cvs/kawa/kawa/kawa/repl.java,v
retrieving revision 1.53
diff -u -w -r1.53 repl.java
--- kawa/repl.java	9 Jan 2004 22:54:38 -0000	1.53
+++ kawa/repl.java	28 Jul 2004 04:28:25 -0000
@@ -41,29 +41,41 @@
     System.exit (-1);
   }
 
+  public static void printOption(PrintStream out, String option, String doc)
+  {
+    out.print(" ");
+    out.print(option);
+
+    int len = option.length() + 1;
+    for (int i = 0; i < 30 - len; ++i)
+      out.print(" ");
+    out.print(" ");
+    out.println(doc);
+  }
+  
   public static void printOptions(PrintStream out)
   {
     out.println("Usage: [java kawa.repl | kawa] [options ...]");
     out.println();
     out.println(" Generic options:");
-    out.println(" --help                    Show help about options");
-    out.println(" --author                  Show author information");
-    out.println(" --version                 Show version information");
+    printOption(out, "--help", "Show help about options");
+    printOption(out, "--author", "Show author information");
+    printOption(out, "--version", "Show version information");
     out.println();
     out.println(" Options");
-    out.println(" -e <expr>                 Evaluate expression <expr>");
-    out.println(" -c <expr>                 Same as -e, but make sure ~/.kawarc.scm is run first");
-    out.println(" -f <filename>             File to interpret");
-    out.println(" -s | --                   Start reading commands interactively from console");
-    out.println(" -w                        Launch the interpreter in a GUI window");
-    out.println(" --server <port>           Start a server accepting telnet connections on <port>");
-    out.println(" --debug-dump-zip          Compiled interactive expressions to a zip archive");
-    out.println(" --debug-print-expr        Print generated internal expressions");
-    out.println(" --debug-print-final-expr  Print expression after any optimizations");
-    out.println(" --[no-]full-tailcalls     (Don't) use full tail-calls");
-    out.println(" -C <filename> ...         Compile named files to Java class files");
-    out.println(" --output-format <format>  Use <format> when printing top-level output");
-    out.println(" --<language>              Select source language, one of:");
+    printOption(out, "-e <expr>", "Evaluate expression <expr>");
+    printOption(out, "-c <expr>", "Same as -e, but make sure ~/.kawarc.scm is run first");
+    printOption(out, "-f <filename>", "File to interpret");
+    printOption(out, "-s| --", "Start reading commands interactively from console");
+    printOption(out, "-w", "Launch the interpreter in a GUI window");
+    printOption(out, "--server <port>", "Start a server accepting telnet connections on <port>");
+    printOption(out, "--debug-dump-zip", "Compiled interactive expressions to a zip archive");
+    printOption(out, "--debug-print-expr", "Print generated internal expressions");
+    printOption(out, "--debug-print-final-expr", "Print expression after any optimizations");
+    printOption(out,"--[no-]full-tailcalls", "(Don't) use full tail-calls");
+    printOption(out, "-C <filename> ...", "Compile named files to Java class files");
+    printOption(out, "--output-format <format>", "Use <format> when printing top-level output");
+    printOption(out,"--<language>", "Select source language, one of:");
     String[][] languages = Interpreter.getLanguages();
     for (int i = 0; i < languages.length; i++)
       {
@@ -78,14 +90,22 @@
 	out.println();
       }
     out.println(" Compilation options, must be specified before -C");
-    out.println(" -d <dirname>              Directory to place .class files in");
-    out.println(" -P <prefix>               Prefix to prepand to class names");
-    out.println(" -T <topname>              name to give ot top-level class");
-    
-    out.println(" --main                    Generate an application, with a main method");
-    out.println(" --applet                  Generate an applet");
-    out.println(" --servlet                 Generate a servlet");
-    out.println(" --module-static           Top-leval definitions are by default static");
+    printOption(out, "-d <dirname>", "Directory to place .class files in");
+    printOption(out, "-P <prefix>", "Prefix to prepand to class names");
+    printOption(out, "-T <topname>", "name to give to top-level class");
+    
+    printOption(out, "--main", "Generate an application, with a main method");
+    printOption(out, "--applet", "Generate an applet");
+    printOption(out, "--servlet", "Generate a servlet");
+    printOption(out, "--module-static", "Top-leval definitions are by default static");
+
+    Vector keys = Compilation.options.keys();
+    for (int i = 0; i < keys.size(); ++i)
+      {
+        String name = (String) keys.get(i);
+        printOption(out, "--" + name, Compilation.options.getDoc(name));
+      }
+        
     out.println();
     out.println("For more information go to:  http://www.gnu.org/software/kawa/";);
   }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]