Repository: pallets/click

Issue:
Reconsider the choice of adding a newline after multi-line option definitions
First, thanks for your work.

I ask you to reconsider the feature introduced with PR https://github.com/pallets/click/pull/1081.

1. Adding a newline only to some options feels inconsistent and leads to a weird-looking "non-uniform" help strings. It's even worse when you use an extension that adds new help sections (e.g. [Cloup](https://github.com/janluke/cloup) for option groups), since some sections are not clearly demarked or too much demarked. It looks like a complete mess.

2. I'm pretty sure it's non-standard. Why should it be the default?

As a consequence, it feels like a bug. I did mistake it for a bug. Another developer reported it as a bug (issue https://github.com/pallets/click/issues/1559). The few people I asked don't like it and consider it a problem worth the effort of writing additional code to get rid of it. Most people in the original issue (https://github.com/pallets/click/issues/1075) are for an all-or-nothing behavior and described the current behviour as inconsistent as well.

Here's some alternative proposals.
1. Remove the feature.
2. Make it possible but non-default. Two solutions here:
    1. Add a parameter to `HelpFormatter`. It can be made as simple as a boolean or as complex as a "list item separation strategy". A user can pass a custom factory function as `Context.formatter_class` (which probably could be called `formatter_factory`).
    2. Refactor `HelpFormatter` to make it easy for people to override without copying, pasting and modiyfing the current code of `HelpFormatter.write_dl`.

Thank you again.



Discussion:
> Refactor HelpFormatter to make it easy for people to override without copying, pasting and modiyfing the current code of HelpFormatter.write_dl.

Yes, as stated in https://github.com/pallets/click/issues/1075#issuecomment-644964531, making the formatting overridable is what I want.
That said, I'm not sure why I accepted it so quickly in the first place, but that was 3 years ago. Feel free to revert it.

Resolving patch:
diff --git a/src/click/formatting.py b/src/click/formatting.py
--- a/src/click/formatting.py
+++ b/src/click/formatting.py
@@ -225,10 +225,6 @@ def write_dl(self, rows, col_max=30, col_spacing=2):
 
                 for line in lines[1:]:
                     self.write(f"{'':>{first_col + self.current_indent}}{line}\n")
-
-                if len(lines) > 1:
-                    # separate long help from next option
-                    self.write("\n")
             else:
                 self.write("\n")
 


Test patch:
diff --git a/tests/test_formatting.py b/tests/test_formatting.py
--- a/tests/test_formatting.py
+++ b/tests/test_formatting.py
@@ -331,42 +331,6 @@ def cli():
     ]
 
 
-def test_formatting_usage_multiline_option_padding(runner):
-    @click.command("foo")
-    @click.option("--bar", help="This help message will be padded if it wraps.")
-    def cli():
-        pass
-
-    result = runner.invoke(cli, "--help", terminal_width=45)
-    assert not result.exception
-    assert result.output.splitlines() == [
-        "Usage: foo [OPTIONS]",
-        "",
-        "Options:",
-        "  --bar TEXT  This help message will be",
-        "              padded if it wraps.",
-        "",
-        "  --help      Show this message and exit.",
-    ]
-
-
-def test_formatting_usage_no_option_padding(runner):
-    @click.command("foo")
-    @click.option("--bar", help="This help message will be padded if it wraps.")
-    def cli():
-        pass
-
-    result = runner.invoke(cli, "--help", terminal_width=80)
-    assert not result.exception
-    assert result.output.splitlines() == [
-        "Usage: foo [OPTIONS]",
-        "",
-        "Options:",
-        "  --bar TEXT  This help message will be padded if it wraps.",
-        "  --help      Show this message and exit.",
-    ]
-
-
 def test_formatting_with_options_metavar_empty(runner):
     cli = click.Command("cli", options_metavar="", params=[click.Argument(["var"])])
     result = runner.invoke(cli, ["--help"])