commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Isuranga Perera (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CLI-264) Short/Long options can be called using either '-' or '--' hyphens with no limitation
Date Mon, 18 Apr 2016 17:49:26 GMT

    [ 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)

Mime
View raw message