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

CLI Parser is not very extension friendly

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.2
    • Component/s: CLI-1.x
    • Labels:
      None

      Description

      The Parser class is not really extension friendly.

      • cmd is private, should either be protected or have a getter/setter pair
      • options and requiredOptions should have getter/setters (requiredOptions depends on options)
      • processProperties is private, should be protected
      • processOptions is private, should be protected
      1. parser.patch
        5 kB
        Henning Schmiedehausen

        Activity

        Hide
        henning Henning Schmiedehausen added a comment -

        BTW: If you are looking for an use case, here it is:

        I have a dynamic Task executor, that has a fixed set of options (list, info, run) and loads an additional set of options depending on the service name given as an argument to list/info/run. So as soon as one of these three has been encountered, I use processOptions to dynamically query the task in question about its options and add it to the running parser.

        (And I do it over JMX, hence I need serializable classes. )

        Show
        henning Henning Schmiedehausen added a comment - BTW: If you are looking for an use case, here it is: I have a dynamic Task executor, that has a fixed set of options (list, info, run) and loads an additional set of options depending on the service name given as an argument to list/info/run. So as soon as one of these three has been encountered, I use processOptions to dynamically query the task in question about its options and add it to the running parser. (And I do it over JMX, hence I need serializable classes. )
        Hide
        bayard Henri Yandell added a comment -

        It all seemed rather unextendable to me. Have you looked at CLI2, and do you have any thoughts on whether that looks more extendable?

        I backed away from making things more extensible rather quickly in CLI1 when I hit bits like that, seemed like a lot of backwards compat issues just waiting to happen.

        Show
        bayard Henri Yandell added a comment - It all seemed rather unextendable to me. Have you looked at CLI2, and do you have any thoughts on whether that looks more extendable? I backed away from making things more extensible rather quickly in CLI1 when I hit bits like that, seemed like a lot of backwards compat issues just waiting to happen.
        Hide
        bayard Henri Yandell added a comment -

        Consider for 1.2; or mark as WONTFIX if 2.0 looks to be better designed for this.

        Show
        bayard Henri Yandell added a comment - Consider for 1.2; or mark as WONTFIX if 2.0 looks to be better designed for this.
        Hide
        henning Henning Schmiedehausen added a comment -

        Legacy application, got it to work with that hack. I might consider moving to CLI 2 in the near future, for now, that patch did the trick for me.

        Show
        henning Henning Schmiedehausen added a comment - Legacy application, got it to work with that hack. I might consider moving to CLI 2 in the near future, for now, that patch did the trick for me.
        Hide
        bayard Henri Yandell added a comment -

        Now 1.1 is out, applying this patch as it looks good.

        Show
        bayard Henri Yandell added a comment - Now 1.1 is out, applying this patch as it looks good.

          People

          • Assignee:
            Unassigned
            Reporter:
            henning Henning Schmiedehausen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development