Skip to content
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

Short help with summary line #1695

Merged
merged 1 commit into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ Unreleased
- Fix formatting when ``Command.options_metavar`` is empty. :pr:`1551`
- The default value passed to ``prompt`` will be cast to the correct
type like an input value would be. :pr:`1517`
- Automatically generated short help messages will stop at the first
ending of a phrase or double linebreak. :issue:`1082`


Version 7.1.2
Expand Down
3 changes: 3 additions & 0 deletions src/click/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def make_str(value):

def make_default_short_help(help, max_length=45):
"""Return a condensed version of help string."""
line_ending = help.find("\n\n")
if line_ending != -1:
help = help[:line_ending]
words = help.split()
total_length = 0
result = []
Expand Down
19 changes: 19 additions & 0 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,3 +528,22 @@ def nope():
assert result.exit_code == 0
assert "subgroup" not in result.output
assert "nope" not in result.output


def test_summary_line(runner):
@click.group()
def cli():
pass

@cli.command()
def cmd():
"""
Summary line without period

Here is a sentence. And here too.
"""
pass

result = runner.invoke(cli, ["--help"])
assert "Summary line without period" in result.output
assert "Here is a sentence." not in result.output