Skip to content

Improve text wrapping #3016

Description

@learn-more

Currently click has 2 modes to display a help text:

  1. Word-wrap the entire blob, and remove all other whitespaces
  2. Preserve newlines, but disable word-wrapping
  1. with a console width of 60, visualized with the *:
************************************************************
Usage: click_wrapping.py [OPTIONS]

Options:
  --test [value1|value2]  Example text to show word
                          wrapping. 'Value1' - short
                          comment. 'Value2' - A longer
                          comment that should wrap to the
                          next line.
  --help                  Show this message and exit.
************************************************************
  1. with a console width of 60, visualized with the *:
************************************************************
Usage: click_wrapping.py [OPTIONS]

Options:
  --test [value1|value2]  Example text to show word wrapping.
                          'Value1' - short comment.
                          'Value2' - A longer comment that should wrap to the next line.
  --help                  Show this message and exit.
************************************************************

The 2nd option is slightly problematic, because on an actual console with width of 60, it looks like this:

************************************************************
Usage: click_wrapping.py [OPTIONS]

Options:
  --test [value1|value2]  Example text to show word wrapping
.
                          'Value1' - short comment.
                          'Value2' - A longer comment that s
hould wrap to the next line.
  --help                  Show this message and exit.
************************************************************

And that should probably be more along the lines of:

************************************************************
Usage: click_wrapping.py [OPTIONS]

Options:
  --test [value1|value2]  Example text to show word
                          wrapping.
                          'Value1' - short comment.
                          'Value2' - A longer comment that
                          should wrap to the next line.
  --help                  Show this message and exit.
************************************************************

Would a PR to fix this be accepted?
(As in, preserve newlines but still wrap on the console width)

Activity

  1. added
    help outputHelp text formatting, layout, and --help rendering
    on Aug 8, 2026
  2. deleted a comment from Ehtasham-Yasin on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help outputHelp text formatting, layout, and --help rendering

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions