click icon indicating copy to clipboard operation
click copied to clipboard

Improve text wrapping

Open learn-more opened this issue 5 months ago • 0 comments

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)

learn-more avatar Jul 25 '25 11:07 learn-more