I'm checking this in.
Tom F. pointed out that the -J argument is joined. This parser
doesn't support that, but this option is special since -J options are
filtered by the driver (in theory -- we don't do this yet AFAIK). So,
I added a hack to help output for this.
Support for joined short options might be nice to have. I didn't do
this initially since I find these options somewhat unfriendly (they
don't work well with completion in bash for one thing) so I prefer to
avoid them.
I also changed long options to print like '-encoding foo' rather than
'-encoding=foo', as the former is more java-y. GNU folks can still
use '=' without thinking about it :-)
Tom
2006-05-09 Tom Tromey <[EMAIL PROTECTED]>
* tools/gnu/classpath/tools/getopt/OptionGroup.java (printHelp):
Special case for '-J'. Use space instead of '='.
* tools/gnu/classpath/tools/getopt/Parser.java (setHeader): Added
comment.
Index: tools/gnu/classpath/tools/getopt/OptionGroup.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java,v
retrieving revision 1.2
diff -u -r1.2 OptionGroup.java
--- tools/gnu/classpath/tools/getopt/OptionGroup.java 9 May 2006 16:52:03
-0000 1.2
+++ tools/gnu/classpath/tools/getopt/OptionGroup.java 9 May 2006 19:21:00
-0000
@@ -147,9 +147,16 @@
{
if (argName != null)
{
- out.print(' ');
+ // This is a silly hack just for '-J'. We don't
+ // support joined options in general, but this option
+ // is filtered out before argument processing can see it.
+ if (option.getShortName() != 'J')
+ {
+ out.print(' ');
+ ++column;
+ }
out.print(argName);
- column += 1 + argName.length();
+ column += argName.length();
}
out.print(" ");
}
@@ -168,7 +175,7 @@
column += (longOnly ? 1 : 2) + option.getLongName().length();
if (argName != null)
{
- out.print("=" + argName);
+ out.print(" " + argName);
column += 1 + argName.length();
}
}
Index: tools/gnu/classpath/tools/getopt/Parser.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/getopt/Parser.java,v
retrieving revision 1.2
diff -u -r1.2 Parser.java
--- tools/gnu/classpath/tools/getopt/Parser.java 9 May 2006 16:52:03
-0000 1.2
+++ tools/gnu/classpath/tools/getopt/Parser.java 9 May 2006 19:21:00
-0000
@@ -120,6 +120,7 @@
{
// -J should be handled by the appletviewer wrapper binary.
// We add it here so that it shows up in the --help output.
+ // Note that there is a special case for this in OptionGroup.
}
});
add(finalGroup);