@@ -124,7 +124,6 @@ public Options() {
124124 // this will not happen ?
125125 }
126126 }
127- System .out .println ( parser .getClass ().getName () );
128127 }
129128
130129 /**
@@ -394,7 +393,7 @@ public CommandLine parse(List inArgs, boolean stopAtNonOption)
394393 CommandLine cl = new CommandLine ();
395394
396395 List args = parser .parse ( this , inArgs , stopAtNonOption );
397-
396+
398397 ListIterator argIter = args .listIterator ();
399398 String eachArg = null ;
400399 Option eachOpt = null ;
@@ -571,27 +570,27 @@ public List getOptions() {
571570 return Collections .unmodifiableList (options );
572571 }
573572
574- /** <p>Retrieve the named {@link Option}<p>
573+ /** <p>Retrieve the named {@link Option}</ p>
575574 *
576575 * @param opt short single-character name of the {@link Option}
577576 * @return the option represented by opt
578577 */
579578 public Option getOption (String opt ) {
580- if ( opt .startsWith ( "--" ) ) {
579+
580+ // short option
581+ if ( opt .length () == 1 ) {
582+ return (Option ) shortOpts .get ( "-" + opt );
583+ }
584+ // long option
585+ else if ( opt .startsWith ( "--" ) ) {
581586 return (Option ) longOpts .get ( opt );
582587 }
583- return (Option ) shortOpts .get ( "-" + opt );
588+ // a just-in-case
589+ else {
590+ return (Option ) shortOpts .get ( opt );
591+ }
584592 }
585593
586- /** <p>Retrieve the named {@link Option}<p>
587- *
588- * @param longOpt long name of the {@link Option}
589- * @return the option represented by longOpt
590- */
591- /*public Option getOption(String longOpt) {
592- return (Option) longOpts.get( longOpt );
593- } */
594-
595594 /** <p>Dump state, suitable for debugging.</p>
596595 *
597596 * @return Stringified form of this object
0 commit comments