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

helpful -help option in a sea of required options

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.2
    • None
    • Options definition, Parser
    • Java obviously.

    Description

      Let's say we have the required options a, b, c, d, e, f, ...., z.

      And we have a single optional option "help".

      So, I enter
      >java blah..blah ..blah mainClass -help.

      It ends up with catching the missing option exception. There is no way of specifying that if -help is supplied then all mandatory options are ignored.

      The way around it is to double parse the args, or to override the parser, the hassle of which defeats the purpose of using CLI.

      You should have a new method

      > public void parse(
      CommandLine cmd, Options options, String[] arguments,
      Properties properties, boolean stopAtNonOption)
      throws ParseException;

      So that, on exception, I could still have a handle to cmd object, which I would determine if "-help" was specified.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Cynthia Avishegnath cynthia avishegnath
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 5m
                  5m
                  Remaining:
                  Remaining Estimate - 5m
                  5m
                  Logged:
                  Time Spent - Not Specified
                  Not Specified