Skip to content
Myr

allow specify short width to address cmd formatting

Before adoption: this commit came in with the history the project adopted, so no landing records it.

try to address the too short short_help width as requested in https://github.com/pallets/click/issues/936

authored by Fletcher Davis · committed by Fletcher Davis · parent 1782e21 · Browse files · 2 files+13 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • https: //github.com/pallets/click/issues/936

Diff stats

2 files+13 added−2 removed

  • tests:+7 added−1 removed
  • other:+6 added−1 removed

2 files+13 added−2 removed

modified:click/core.py+6 added-1 removed
767 unmodified lines
768 self.help = help769 self.epilog = epilog770 self.options_metavar = options_metavar771 if short_help is None and help:772 if (context_settings is not None and773 'short_help_width' in context_settings):774 short_width = context_settings.get('short_help_width')775 short_help = make_default_short_help(help, short_width)776 else:772 short_help = make_default_short_help(help)777 short_help = make_default_short_help(help)778 self.short_help = short_help779 self.add_help_option = add_help_option780 self.hidden = hidden781
1014 unmodified lines
modified:tests/test_commands.py+7 added-1 removed
57 unmodified lines
58 def long():59 """This is a long text that is too long to show as short help60 and will be truncated instead."""6162 @cli.command(context_settings={'short_help_width': 20})63 def width():64 """This is a long text that is too long to show as short help65 and will be truncated instead."""6667 result = runner.invoke(cli, ['--help'])68 assert re.search(69 r'Commands:\n\s+'70 r'long\s+This is a long text that is too long to show\.\.\.\n\s+'71 r'short\s+This is a short text\.\n\s+'67 r'special-chars\s+Login and store the token in ~/.netrc\.\s*',72 r'special-chars\s+Login and store the token in ~/.netrc\.\s+'73 r'width\s+This is a long text\.\.\.\n\s*',74 result.output) is not None757677def test_default_maps(runner):
246 unmodified lines