diff --git a/src/click/formatting.py b/src/click/formatting.py index de2ca4711..2f0dda47a 100644 --- a/src/click/formatting.py +++ b/src/click/formatting.py @@ -158,6 +158,10 @@ def write_usage(self, prog: str, args: str = "", prefix: str | None = None) -> N usage_prefix = f"{prefix:>{self.current_indent}}{prog} " text_width = self.width - self.current_indent + if not args: + self.write(f"{prefix:>{self.current_indent}}{prog}\n") + return + if text_width >= (term_len(usage_prefix) + 20): # The arguments will fit to the right of the prefix. indent = " " * term_len(usage_prefix)