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

Error parsing options a-la Java property option

    XMLWordPrintableJSON

Details

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

    • 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

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

            Dates

              Created:
              Updated:
              Resolved: