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

Error parsing options a-la Java property option

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 2.0
    • Component/s: CLI-2.x
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: PC

    • Bugzilla Id:
      16484

      Description

      import org.apache.commons.cli.*;

      public class Test {

      public static void main( String[] args ) {

      try {

      Options options = new Options();

      options.addOption( OptionBuilder

      .hasArg()

      .withDescription( "Define a system property" )

      .create( 'D' ) );

      CommandLineParser parser = new PosixParser();

      CommandLine cl = parser.parse( options, args );

      for (java.util.Iterator i = cl.iterator(); i.hasNext(); )

      { System.err.println(i.next()); }

      System.err.println(cl.getArgList());

      } catch (Throwable e)

      { e.printStackTrace(); }

      }

      }

      HOW TO REPRODUCE:

      Compile this example and run for example

      java -cp commons-cli-1.0-beta-2.jar:. Test -Da=b -Dc=d xxx

      OBSERVED RESULT:

      [ option: D :: Define a system property ]

      [c=d, xxx]

      EXPECTED RESULT:

      [ option: D :: Define a system property ]

      [ option: D :: Define a system property ]

      [xxx]

      ADDITIONAL INFO:

      The error occured only in 1.0 version, versions 1.0-beta-2 and 1.0-beta-2-dev
      have no such problem.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              barancev Alexei Barantsev
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: