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

[cli] Not handling property=value followed by 'remaining' args

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0
    • 2.0
    • CLI-2.x
    • None
    • Operating System: other
      Platform: Other

    • 34228

    Description

      If you have a command line args similar to

      domything -Dmyprop1=myval1 -Dmyprop2=myval2 myfile

      I would expect to be able to set up the 'D' option so that

      String[] opts = line.getOptionValues( "D" );
      assertEquals( "myprop1", opts[0] );
      assertEquals( "myval1", opts[1] );
      assertEquals( "myprop2", opts[2] );
      assertEquals( "myval2", opts[3] );

      String[] xtraArgs = line.getArgs();
      assertEquals( "myfile", xtraArgs[0]);

      But, setting up similar to the ApplicationTest.java I get 'myfile' as opts
      [4]. Since we have set up the 'D' option with hasArgs, it will only stop
      adding args to 'D' when it runs into another valid option, not an extra arg.
      If you set up the 'D' option with hasArg (singular) then it myprop1=myval1
      gets reported as an invalid option.

      I've glanced at the source but didn't see an obvious fix that wouldn't
      jeopardize the combinations and permutations that Option.addValue() must deal
      with.

      Attachments

        Activity

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

          People

            Unassigned Unassigned
            jskufca@ud.com Jim Skufca
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment