Skip to content

Add WrappedColorFormatter to contrib. #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jlevy
Copy link

@jlevy jlevy commented Apr 10, 2025

Thanks for the great lib. A peeve of mine is that it can be hard to read argparse help on wide terminals. This is my preferred formatter now for my projects so thought I'd add it to contrib!

@RomainBrault
Copy link

RomainBrault commented Apr 18, 2025

Currently you can also get the same result with functools.partial.

@hamdanal
Copy link
Owner

hamdanal commented May 1, 2025

Thanks for your contribution.
Text width is a property that affects all formatters, it should not have its own formatter. There are many solutions that work now:

  1. You can use a lambda, functools.partial or a subclass of your favorite formatter to set the width as suggested by the comment above
  2. The better option is to set the COLUMNS variable in your shell's dotfiles and have all your terminal output wrapped to your favorite terminal width. This is the best option as this way you don't impose your choice of narrow screen on users of your tools (plus this will work for tools that don't use rich-argparse).

I don't think this should be in rich-argparse. If you disagree we can look into ways to make it usable with all formatters, no new formatter needs to be defined. Before we do though, we should look to see if there is an existing standard or convention similar to the $COLUMNS var that sets the maximum width.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants