Repository: pallets/click

Issue:
get help does not remove multiline marker
if You have commands with a multi-line help, the `\b` is not brushed off the help output 

if You use -h it looks correct in the terminal :
```
$> cli_command -h 
Usage: test_cli_help.py [OPTIONS] COMMAND [ARGS]...

  some help

 Options:
   --version   Show the version and exit.
   -h, --help  Show this message and exit.

 Commands:
   command1  command1 without arguments and options
   command2  command2 with arguments
   command3  command3 with multi line help arguments and options
   command4  command4 with arguments, options and sub_command and a very...
```

but if You parse the text, You will see that the `\b` is not brushed off, where it should be,
see the ` `  near command3, command4. instead of brushing off the `\b`, You just added one whitespace. 

```
$> cli_command -h > ./help.txt

# Content of ./help.txt : 
Usage: test_cli_help.py [OPTIONS] COMMAND [ARGS]...

  some help

 Options:
   --version   Show the version and exit.
   -h, --help  Show this message and exit.

 Commands:
   command1  command1 without arguments and options
   command2  command2 with arguments
   command3   command3 with multi line help arguments and options
   command4   command4 with arguments, options and sub_command and a very...
```

this is my example:

```python
# EXT
import click

# CONSTANTS
CLICK_CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
CLICK_CONTEXT_SETTINGS_NO_HELP = dict(help_option_names=[])


@click.group(help='some help', context_settings=CLICK_CONTEXT_SETTINGS)
@click.version_option(version='1.1.1',
                      prog_name='program name',
                      message='{} version %(version)s'.format('cli command'))
def cli_main() -> None:             # pragma: no cover
    pass                            # pragma: no cover


# command1 without arguments and options
@cli_main.command('command1', context_settings=CLICK_CONTEXT_SETTINGS_NO_HELP)
def cli_command1() -> None:         # pragma: no cover
    """ command1 without arguments and options """
    pass


# command2 with arguments
@cli_main.command('command2', context_settings=CLICK_CONTEXT_SETTINGS)
@click.argument('argument1')
@click.argument('argument2')
def cli_command2(argument1: str, argument2: str) -> None:
    """ command2 with arguments """
    pass                            # pragma: no cover


# command3 with arguments and options
@cli_main.command('command3', context_settings=CLICK_CONTEXT_SETTINGS)
@click.argument('argument1')
@click.argument('argument2')
@click.option('-a', '--a_option', is_flag=True)             # no help here
@click.option('-b', '--b_option', type=int, default=-1, help='help for b_option')
@click.option('-c', '--c_option', help='help for c_option')
def cli_command3(argument1: str, argument2: str, a_option: bool, b_option: int, c_option: str) -> None:
    """\b
        command3 with multi
        line help arguments and options
        """
    pass                            # pragma: no cover


# command4 with arguments, options and sub_command
# groups must not have arguments or we can not parse them
# because to get help for the sub command we need to put :
# program command4 arg1 arg2 command5 -h
# and we dont know the correct type of arg1, arg2

@cli_main.group('command4', context_settings=CLICK_CONTEXT_SETTINGS)
@click.argument('argument1')
@click.argument('argument2')
@click.option('-a', '--a_option', is_flag=True)             # no help here
@click.option('-b', '--b_option', type=int, default=-1, help='help for b_option')
@click.option('-c', '--c_option', help='help for c_option')
def cli_command4(argument1: str, argument2: str, a_option: bool, b_option: int, c_option: str) -> None:
    """\b
     command4 with arguments,
     options and sub_command
     and a very long
     multiline help
     what for sure will not fit into one terminal line
     what for sure will not fit into one terminal line
     what for sure will not fit into one terminal line
     what for sure will not fit into one terminal line
     """
    pass                            # pragma: no cover


# command5, sub_command of command4 with arguments, options
@cli_command4.command('command5', context_settings=CLICK_CONTEXT_SETTINGS)
@click.argument('argument1')
@click.argument('argument2')
@click.option('-a', '--a_option', is_flag=True)             # no help here
@click.option('-b', '--b_option', type=int, default=-1, help='help for b_option')
@click.option('-c', '--c_option', help='help for c_option')
def cli_command5(argument1: str, argument2: str, a_option: bool, b_option: int, c_option: str) -> None:
    """command5, sub_command of command4 with arguments, options"""
    pass                            # pragma: no cover


# entry point if main
if __name__ == '__main__':
    cli_main()
```

* Click version: latest


Discussion:
This can be avoided by adding a short_help or a summary at the start of the doc string. Below is a patch that would handle the example:

```diff
diff --git a/src/click/utils.py b/src/click/utils.py
index 0bff5c0..89d726d 100644
--- a/src/click/utils.py
+++ b/src/click/utils.py
@@ -54,6 +54,13 @@ def make_default_short_help(help, max_length=45):
     result = []
     done = False

+    # Use only the first line when string shouldn't be rewrapped.
+    if words[0] == '\b':
+        for line in help.splitlines():
+            if line and line != '\b':
+                words = line.split()
+                break
+
     for word in words:
         if word[-1:] == ".":
             done = True
```
Hey, I'm a fellow from MLH. I'd like to work on this issue.

Resolving patch:
diff --git a/src/click/utils.py b/src/click/utils.py
--- a/src/click/utils.py
+++ b/src/click/utils.py
@@ -57,6 +57,9 @@ def make_default_short_help(help, max_length=45):
     result = []
     done = False
 
+    if words[0] == "\b":
+        words = words[1:]
+
     for word in words:
         if word[-1:] == ".":
             done = True


Test patch:
diff --git a/tests/test_formatting.py b/tests/test_formatting.py
--- a/tests/test_formatting.py
+++ b/tests/test_formatting.py
@@ -296,6 +296,25 @@ def cli(ctx):
     ]
 
 
+def test_removing_multiline_marker(runner):
+    @click.group()
+    def cli():
+        pass
+
+    @cli.command()
+    def cmd1():
+        """\b
+        This is command with a multiline help text
+        which should not be rewrapped.
+        The output of the short help text should
+        not contain the multiline marker.
+        """
+        pass
+
+    result = runner.invoke(cli, ["--help"])
+    assert "\b" not in result.output
+
+
 def test_global_show_default(runner):
     @click.command(context_settings=dict(show_default=True))
     @click.option("-f", "in_file", default="out.txt", help="Output file name")