commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adrien CABARBAYE (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CLI-264) Short/Long options can be called using either '-' or '--' hyphens with no limitation
Date Tue, 05 Apr 2016 16:29:25 GMT

     [ https://issues.apache.org/jira/browse/CLI-264?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Adrien CABARBAYE updated CLI-264:
---------------------------------
    Description: 
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.

  was:
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.


> 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