Skip to content
Myr

Merge pull request #1081 from pwlandoll/feature/1075

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

Feature/1075 - Adding newline after multi-line help strings

authored by David Lord · committed by GitHub · parents 3307fc0, 7b1429d · Browse files · 3 files+43 added−1 removed
This commit

State

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

Diff stats

3 files+43 added−1 removed

  • tests:+37 added−1 removed
  • other:+6 added−0 removed

3 files+43 added−1 removed

modified:click/formatting.py+4 added
204 unmodified lines
205 self.write(lines[0] + '\n')206207 for line in lines[1:]:208 self.write('%*s%s\n' % (first_col + self.current_indent, '', line))209210 if len(lines) > 1:211 # separate long help from next option212 self.write("\n")213 else:214 self.write('\n')215216 @contextmanager
46 unmodified lines
modified:tests/test_formatting.py+37 added-1 removed
310 unmodified lines
311 '',312 'Options:',313 ' -f TEXT Output file name [default: out.txt]',314 ' --help Show this message and exit. [default: False]'315 ]315 ]316317318def test_formatting_usage_multiline_option_padding(runner):319 @click.command('foo')320 @click.option('--bar', help='This help message will be padded if it wraps.')321 def cli():322 pass323324 result = runner.invoke(cli, '--help', terminal_width=45)325 assert not result.exception326 assert result.output.splitlines() == [327 'Usage: foo [OPTIONS]',328 '',329 'Options:',330 ' --bar TEXT This help message will be',331 ' padded if it wraps.',332 '',333 ' --help Show this message and exit.'334 ]335336337def test_formatting_usage_no_option_padding(runner):338 @click.command('foo')339 @click.option('--bar', help='This help message will be padded if it wraps.')340 def cli():341 pass342343 result = runner.invoke(cli, '--help', terminal_width=80)344 assert not result.exception345 assert result.output.splitlines() == [346 'Usage: foo [OPTIONS]',347 '',348 'Options:',349 ' --bar TEXT This help message will be padded if it wraps.',350 ' --help Show this message and exit.'351 ]
modified:CHANGES.rst+2 added
47 unmodified lines
48 containing ``-``. :issue:`1253`49- Option help text replaces newlines with spaces when rewrapping, but50 preserves paragraph breaks, fixing multiline formatting.51 :issue:`834, 1066, 1397`52- Option help text that is wrapped adds an extra newline at the end to53 distinguish it from the next option. :issue:`1075`545556Version 7.057-----------
540 unmodified lines