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

Prefix ignored with DefaultOption

    XMLWordPrintableJSON

Details

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

    • 30979

    Description

      I created the same Option using DefaultOption and DefaultOptionBuilder but
      they behave differently for short (and I am guessing for long as well)
      prefixes. With DefaultOptionBuilder, the preferredName for an Option
      becomes "shortPrefix" + "shortName". With DefaultOption, the preferredName
      remains the "preferredName" supplied in the constructor, when I think it
      should become "shortPrefix"/"longPrefix" + "preferredName"

      For example:

      DefaultOption optionName =
      new DefaultOption(
      "-",
      "--",
      false,
      "n",
      "Print greeting",
      null,
      null,
      true,
      null,
      null,
      'n');

      When used on the command line, it will require "MyApplication n" instead
      of "MyApplication -n".

      The same created using the builder:

      DefaultOptionBuilder oBuilder = new DefaultOptionBuilder();
      Option optionName =
      oBuilder
      .withShortName("n")
      .withDescription("Print standard greeting")
      .create();

      will require "MyApplication -n" and not "MyApplication n" which would be the
      expected behaviour.


      Vikram

      Attachments

        Activity

          People

            Unassigned Unassigned
            gvix Vikram Goyal
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: