Repository navigation
Closed
Labels
help outputHelp text formatting, layout, and --help rendering
Description
The help text of some options seems to be wrapped arbitrarily and in a very ugly way. I’m not sure if this is a bug or my fault:
$ mpw --help
Usage: mpw [OPTIONS] SITE
Calculate a site password based on your master password.
Options:
-u TEXT Full name of the user.
-t TEXT The password template to use:
- max 20 characters, contains
symbols
- long 14 characters, contains symbols
- medium 8
characters, contains symbols
- basic 8 characters, no symbols
- short 4 characters, no symbols
- pin 4 numbers
-c INTEGER The value for the counter.
--help Show this message and exit.
Obviously, the text fits into the line (see the line - long 14 ....) but other lines are wrapped.
The code to reproduce it:
import click
@click.command()
@click.option('-u', 'user',
help='Full name of the user.')
@click.option('-t', 'pwd_type', default='long',
help="""The password template to use:
- max 20 characters, contains symbols
- long 14 characters, contains symbols
- medium 8 characters, contains symbols
- basic 8 characters, no symbols
- short 4 characters, no symbols
- pin 4 numbers""")
@click.option('-c', 'counter', default=1,
help='The value for the counter.')
@click.argument('site')
def main(site, user, pwd_type, counter):
"""Calculate a site password based on your master password."""
click.echo(site)
click.echo(user)
click.echo(pwd_type)
click.echo(counter)
if __name__ == '__main__':
main()click 3.1
Python 3.4.1
OS X Mavericks
Metadata
Metadata
Assignees
Labels
help outputHelp text formatting, layout, and --help rendering
Activity
mitsuhiko commentedon Aug 21, 2014
The parameter part of options gets rewrapped to fit the terminal size. I would not try to be super clever with formatting on a per parameter basis. That said, maybe it would make sense to have a mode to disable rewrapping or to control it better.
sscherfke commentedon Aug 21, 2014
Yes, that would be useful. :-)
Until then, I’ll move the list to
main’s docstring and prepend a\b.untitaker commentedon Aug 21, 2014
Maybe accept a "list of lines" and wrap each of them individually?
lubomir commentedon Jan 12, 2015
Depending on the length of the actual file name the help output of the following script can get pretty weird:
Obviously the second argument would fit on the second line unwrapped.
timstaley commentedon Jan 2, 2017
As mentioned in issue #441, you can control the wrapping-width by setting
max_content_widthin thecontext_settingsdict parameter of click.command, e.g.jcrotts commentedon May 15, 2018
Closing this, timstaley's answer lets you set the wrapping-width.
If you need to do extra formatting on the help text #255 has an example.
reberac commentedon Oct 15, 2018
Hi,
It does not work for me...
The help text of some options is still wrapped arbitrarily (I see an impact when I fix max_content_width with a value lower than 80, however no change with a value greater than the default one.
I use :
click-7.0
Python 3.6.6 :: Anaconda custom (64-bit)
Mac El Capitan 10.11.6
Any suggestion ?
Thanks in advance
Aurélie
espdev commentedon Nov 28, 2019
@reberac +1
It does not work for me.
@jcrotts
It does not work in all cases. Currently, I cannot control how parameter help text will be formatted.
JeCarl commentedon Jan 8, 2020
I got uncontrolled linebreaks too.
Just like in the example from @espdev with the "drop-paths"
Increasing the max_content_width did not solve the problem for me.
Has anyone one found already a solution ?