Issue Details (XML | Word | Printable)

Key: CLI-154
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: HAUTION Philippe
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Commons CLI

Incomplete usage documentation about Java property option

Created: 30/Apr/08 09:00 AM   Updated: 06/Feb/09 06:59 AM
Return to search
Component/s: Documentation
Affects Version/s: 1.0, 1.1
Fix Version/s: 1.2

Time Tracking:
Original Estimate: 1h
Original Estimate - 1h
Remaining Estimate: 1h
Remaining Estimate - 1h
Time Spent: Not Specified
Remaining Estimate - 1h

Resolution Date: 13/Jun/08 05:15 PM


 Description  « Hide
On Usage Scenarios page http://jakarta.apache.org/commons/cli/usage.html, in the "Java property option" section of "Ant example", after the creation of the property Option, ie :

Option property = OptionBuilder.withArgName( "property=value" )
.hasArg()
.withValueSeparator()
.withDescription( "use value for given property" )
.create( "D" );

One should add :

property.setArgs(Option.UNLIMITED_VALUES);

for the example to work properly.

In the "Querying the commandline" section, the code line :
this.buildfile = line.getValue( "buildfile" );

should be :
this.buildfile = line.getOptionValue( "buildfile" );

Also some parsing code could be given about the special property option, for instance :

Properties props = new Properties();

if( line.hasOption( "D" ) ) {

String[] args = line.getOptionValues( "D" );

for (int i = 0; i < args.length; i += 2) { String propertyName = args[i]; String propertyValue = null; if (i + 1 < args.length) propertyValue = args[i + 1]; props.put(propertyName, propertyValue); }
}



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
No work has yet been logged on this issue.