Uploaded image for project: 'Commons CLI'
  1. Commons CLI
  2. CLI-264

Short/Long options can be called using either '-' or '--' hyphens with no limitation

Agile BoardAttach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.3.1
    • None
    • CLI-1.x

    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.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            acabarbaye Adrien CABARBAYE

            Dates

              Created:
              Updated:

              Slack

                Issue deployment