You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Isuranga Perera (JIRA)" <ji...@apache.org> on 2016/04/18 19:49:26 UTC
[jira] [Commented] (CLI-264) Short/Long options can be called using
either '-' or '--' hyphens with no limitation
[ https://issues.apache.org/jira/browse/CLI-264?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15246132#comment-15246132 ]
Isuranga Perera commented on CLI-264:
-------------------------------------
Above problem is a common problem to both DeafultParser and BasicParser (which is a depreciated version). So both versions have to be debugged.
> Short/Long options can be called using either '-' or '--' hyphens with no limitation
> ------------------------------------------------------------------------------------
>
> Key: CLI-264
> URL: https://issues.apache.org/jira/browse/CLI-264
> Project: Commons CLI
> Issue Type: Bug
> Components: CLI-1.x
> Affects Versions: 1.3.1
> Reporter: Adrien CABARBAYE
> Labels: features
>
> When using DefaultParser, any options can be accessed using either '\-' or '\-\-' as a prefix and so regardless whether they have been defined as short or long.
> the problem is in handleToken:
> 237 else if (token.startsWith("\-\-"))
> 238 {
> 239 handleLongOption(token);
> 240 }
> 241 else if (token.startsWith("\-") && !"\-".equals(token))
> 242 {
> 243 handleShortAndLongOption(token);
> 244 }
> Some logic should be added so that if an option has been defined as short (e.g. \-h), if \-\-h is used, for instance, in the command line, an exception should be raised. Similarly for long options which are being called using only '\-' instead of '\-\-' as a prefix, an exception should also be fired.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)