Hi everyone,
First of all, let me express my gratitude and appreciation to every
contributor of CLI.
It has made my life so much easier when it comes to command line.
By the way, while using the CLI, I found a couple of small problems
which I have
taken the liberty to experiment fixing. I sent the suggestion to Bob
McWhirter
and he referred me to this list.
HelpFormatter.java (4 suggestions)
==================================
1. A printUsage that does not require PrintWriter but uses System.out.
2. The !" ".equals( option.getOpt() ) checking needs a null checking
when only longOpt is set.
3. Use "<" and ">" to wrap around argName / argDescription for legibility?
4. Use description if argName is not set, provided description is set.
Index: src/java/org/apache/commons/cli/HelpFormatter.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/cli/src/java/org/apache/commons/cli/HelpFormatter.java,v
retrieving revision 1.10
diff -u -r1.10 HelpFormatter.java
--- src/java/org/apache/commons/cli/HelpFormatter.java 15 Nov 2002
22:22:47 -0000 1.10
+++ src/java/org/apache/commons/cli/HelpFormatter.java 18 Nov 2002
21:40:30 -0000
@@ -213,6 +213,14 @@
}
}
+ public void printUsage( int width, String app, Options options )
+ {
+ PrintWriter pw = new PrintWriter(System.out);
+ printUsage( pw, width, app, options );
+ pw.flush();
+ }
+
+
/**
* <p>Prints the usage statement for the specified application.</p>
*
@@ -270,7 +278,7 @@
buff.append( "[" );
}
- if( !" ".equals( option.getOpt() ) ) {
+ if( option.getOpt() != null && !" ".equals(
option.getOpt() ) ) {
buff.append( "-" ).append( option.getOpt() );
}
else {
@@ -279,7 +287,9 @@
// if the Option has a value
if( option.hasArg() && option.getArgName() != null ) {
- buff.append( " " ).append( option.getArgName() );
+ buff.append( " <" ).append( option.getArgName()
).append( ">" );
+ } else if ( option.getDescription() != null ) {
+ buff.append( " <" ).append( option.getDescription()
).append( ">" );
}
// if the Option is not a required option
Best regards,
Boon Hian Tek
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
