You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "HAUTION Philippe (JIRA)" <ji...@apache.org> on 2008/04/30 11:18:55 UTC
[jira] Created: (CLI-154) Incomplete usage documentation about Java
property option
Incomplete usage documentation about Java property option
---------------------------------------------------------
Key: CLI-154
URL: https://issues.apache.org/jira/browse/CLI-154
Project: Commons CLI
Issue Type: Bug
Components: CLI-1.x
Affects Versions: 1.1, 1.0, 1.2
Reporter: HAUTION Philippe
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);
}
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CLI-154) Incomplete usage documentation about
Java property option
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CLI-154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12595132#action_12595132 ]
Henri Yandell commented on CLI-154:
-----------------------------------
The first one appears to be a result of the change from unlimited to one value reported in CLI-137. Change will depend on the resolution to that issue.
I've fixed the second one.
Haven't looked at the third one yet.
> Incomplete usage documentation about Java property option
> ---------------------------------------------------------
>
> Key: CLI-154
> URL: https://issues.apache.org/jira/browse/CLI-154
> Project: Commons CLI
> Issue Type: Bug
> Components: CLI-1.x
> Affects Versions: 1.0, 1.1
> Reporter: HAUTION Philippe
> Fix For: 1.2
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> 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);
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CLI-154) Incomplete usage documentation about
Java property option
Posted by "Emmanuel Bourg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CLI-154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12604917#action_12604917 ]
Emmanuel Bourg commented on CLI-154:
------------------------------------
Now that CLI-137 is fixed I changed the doc to use hasArgs(2) instead of hasArgs(), otherwise the -D option collects the remaning arguments (for example with -Dfoo=bar myapp.jar, the option would receive the jar as its 3rd value)
Regarding the parsing of the properties, the current API is clearly inconvenient. The CommandLine class should provide a method to access them easily, something like:
{code:java}
Properties props = cmdline.getOptionProperties("D");
String value = props.get("foo");
{code}
> Incomplete usage documentation about Java property option
> ---------------------------------------------------------
>
> Key: CLI-154
> URL: https://issues.apache.org/jira/browse/CLI-154
> Project: Commons CLI
> Issue Type: Bug
> Components: Documentation
> Affects Versions: 1.0, 1.1
> Reporter: HAUTION Philippe
> Fix For: 1.2
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> 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);
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CLI-154) Incomplete usage documentation about
Java property option
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CLI-154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12601023#action_12601023 ]
Henri Yandell commented on CLI-154:
-----------------------------------
The hasArg->hasArgs change has been made.
> Incomplete usage documentation about Java property option
> ---------------------------------------------------------
>
> Key: CLI-154
> URL: https://issues.apache.org/jira/browse/CLI-154
> Project: Commons CLI
> Issue Type: Bug
> Components: Documentation
> Affects Versions: 1.0, 1.1
> Reporter: HAUTION Philippe
> Fix For: 1.2
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> 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);
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CLI-154) Incomplete usage documentation about
Java property option
Posted by "HAUTION Philippe (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CLI-154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12595220#action_12595220 ]
HAUTION Philippe commented on CLI-154:
--------------------------------------
Yes, you are right, using Option.hasArgs() instead of Option.hasArg() is a simpler solution to the first issue than doing a .setArgs(Option.UNLIMITED_VALUES).
> Incomplete usage documentation about Java property option
> ---------------------------------------------------------
>
> Key: CLI-154
> URL: https://issues.apache.org/jira/browse/CLI-154
> Project: Commons CLI
> Issue Type: Bug
> Components: CLI-1.x
> Affects Versions: 1.0, 1.1
> Reporter: HAUTION Philippe
> Fix For: 1.2
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> 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);
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (CLI-154) Incomplete usage documentation about
Java property option
Posted by "Emmanuel Bourg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CLI-154?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Emmanuel Bourg resolved CLI-154.
--------------------------------
Resolution: Fixed
Method added and documented.
> Incomplete usage documentation about Java property option
> ---------------------------------------------------------
>
> Key: CLI-154
> URL: https://issues.apache.org/jira/browse/CLI-154
> Project: Commons CLI
> Issue Type: Bug
> Components: Documentation
> Affects Versions: 1.0, 1.1
> Reporter: HAUTION Philippe
> Fix For: 1.2
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> 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);
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CLI-154) Incomplete usage documentation about
Java property option
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CLI-154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12595133#action_12595133 ]
Henri Yandell commented on CLI-154:
-----------------------------------
Additionally, looks like the solution to the first is to have .hasArgs() rather than .hasArg()
> Incomplete usage documentation about Java property option
> ---------------------------------------------------------
>
> Key: CLI-154
> URL: https://issues.apache.org/jira/browse/CLI-154
> Project: Commons CLI
> Issue Type: Bug
> Components: CLI-1.x
> Affects Versions: 1.0, 1.1
> Reporter: HAUTION Philippe
> Fix For: 1.2
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> 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);
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (CLI-154) Incomplete usage documentation about Java
property option
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CLI-154?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henri Yandell updated CLI-154:
------------------------------
Affects Version/s: (was: 1.2)
Fix Version/s: 1.2
> Incomplete usage documentation about Java property option
> ---------------------------------------------------------
>
> Key: CLI-154
> URL: https://issues.apache.org/jira/browse/CLI-154
> Project: Commons CLI
> Issue Type: Bug
> Components: CLI-1.x
> Affects Versions: 1.0, 1.1
> Reporter: HAUTION Philippe
> Fix For: 1.2
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> 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);
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (CLI-154) Incomplete usage documentation about Java
property option
Posted by "Emmanuel Bourg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CLI-154?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Emmanuel Bourg updated CLI-154:
-------------------------------
Component/s: (was: CLI-1.x)
Documentation
> Incomplete usage documentation about Java property option
> ---------------------------------------------------------
>
> Key: CLI-154
> URL: https://issues.apache.org/jira/browse/CLI-154
> Project: Commons CLI
> Issue Type: Bug
> Components: Documentation
> Affects Versions: 1.0, 1.1
> Reporter: HAUTION Philippe
> Fix For: 1.2
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> 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);
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.