You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by jk...@apache.org on 2002/06/19 23:28:45 UTC
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli Options.java
jkeyes 2002/06/19 14:28:45
Modified: cli/src/java/org/apache/commons/cli Options.java
Log:
removed old getOption method, fixed new getOption impl, removed duff println
Revision Changes Path
1.3 +13 -14 jakarta-commons/cli/src/java/org/apache/commons/cli/Options.java
Index: Options.java
===================================================================
RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Options.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Options.java 16 Jun 2002 23:00:58 -0000 1.2
+++ Options.java 19 Jun 2002 21:28:45 -0000 1.3
@@ -124,7 +124,6 @@
// this will not happen ?
}
}
- System.out.println( parser.getClass().getName() );
}
/**
@@ -394,7 +393,7 @@
CommandLine cl = new CommandLine();
List args = parser.parse( this, inArgs, stopAtNonOption );
-
+
ListIterator argIter = args.listIterator();
String eachArg = null;
Option eachOpt = null;
@@ -571,26 +570,26 @@
return Collections.unmodifiableList(options);
}
- /** <p>Retrieve the named {@link Option}<p>
+ /** <p>Retrieve the named {@link Option}</p>
*
* @param opt short single-character name of the {@link Option}
* @return the option represented by opt
*/
public Option getOption(String opt) {
- if( opt.startsWith( "--" ) ) {
+
+ // short option
+ if( opt.length() == 1 ) {
+ return (Option) shortOpts.get( "-" + opt );
+ }
+ // long option
+ else if( opt.startsWith( "--" ) ) {
return (Option) longOpts.get( opt );
}
- return (Option) shortOpts.get( "-" + opt );
+ // a just-in-case
+ else {
+ return (Option) shortOpts.get( opt );
+ }
}
-
- /** <p>Retrieve the named {@link Option}<p>
- *
- * @param longOpt long name of the {@link Option}
- * @return the option represented by longOpt
- */
- /*public Option getOption(String longOpt) {
- return (Option) longOpts.get( longOpt );
- } */
/** <p>Dump state, suitable for debugging.</p>
*
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>