airlift / airline

Java annotation-based framework for parsing Git like command line structures

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

help to include allowedValues, and respect multi-line descriptions

aledsage opened this issue · comments

Part one...

I have an option where I define allowed values, but help doesn't show what those allowed values are.

    @Option(name = { "--persist" }, allowedValues = { "disabled", "auto", "rebind", "clean" }, title = "persistance mode", description = "The persistence mode.")

Help just shows:

    --persist <persistance mode>
        The persistence mode.

Part two...

I want to include in the description what each of these allowed values means. It looks like my only option is to include that in description, so I wrote the following code:

    @Option(name = { "--persist" }, allowedValues = { "disabled", "auto", "rebind", "clean" },
            title = "persistance mode",
            description = "The persistence mode. Possible values are:\n"+
                    "disabled: will not read or persist any state; \n"+
                    "auto: will rebind to any existing state, or start up fresh if no state; \n"+
                    "rebind: will rebind to the existing state, or fail if no state available; \n"+
                    "clean: will start up fresh (not using any existing state)")

However, this discarded my new-line characters to just split the lines at 79 characters, wherever that happened to occur (presumably due to the code in https://github.com/airlift/airline/blob/master/src/main/java/io/airlift/airline/UsagePrinter.java append).

    --persist <persistance mode>
        The persistence mode. Possible values are: disabled: will not read
        or persist any state; auto: will rebind to any existing state, or
        start up fresh if no state; rebind: will rebind to any existing
        state, or fail if no state available; clean: will start up fresh
        (not using any existing state)

Note I can't work around this by padding the lines with spaces, because UsagePrinter. append has split on white space, trimming each word.