Skip to content

Commit e56f1e1

Browse files
author
John Keyes
committed
removed old getOption method, fixed new getOption impl, removed duff println
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/cli/trunk@129772 13f79535-47bb-0310-9956-ffa450edef68
1 parent ead3757 commit e56f1e1

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

src/java/org/apache/commons/cli/Options.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)