pallets / pallets/click

Improve text wrapping

Open
#3,016 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help output
Dominant language
Python
Stars
17.7k
Forks
2.3k
Avg merge
1d 30m
Merged PRs (30d)
18

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Click's text-wrapping behavior described in the linked documentation and reproduce the examples at console width 60. Trace the help-text formatting entry point and add coverage for preserving newlines while still wrapping to the console width; done means long lines no longer overflow or split words unexpectedly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.