Skip to content

Dynamically adjust width of long option name column #360

@remkop

Description

@remkop

The current layout (up to and including 3.0-alpha-6) has a fixed width long option name column:
this column is always 24 characters, even if none of the options have a long option name.

This gives weird-looking usage help messages in some cases. For example:

def cli = new CliBuilder(name:'ls')
cli.a('display all files')
cli.l('use a long listing format')
cli.t('sort by modification time')
def options = cli.parse(args)
...

The usage message for this example is:

Usage: ls [-alt]
  -a                          display all files
  -l                          use a long listing format
  -t                          sort by modification time

Picocli should adjust the width of the long option name column to the longest name (max 24).

Side note: the effective max width for long options is 20, since 4 characters out of that 24 are padding: 1 initial leading space, and 3 trailing spaces. Long options that are longer than 20 characters cause the long option column to "overflow" into the description column, and description to be displayed on the next line.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions