From 64fd2bda82f3c3cd21549c9a9daeca1cc6e110b6 Mon Sep 17 00:00:00 2001 From: Crypto Nite Date: Fri, 15 May 2026 19:18:33 -0700 Subject: [PATCH] Fix write_usage with empty args producing no output When write_usage is called with no args (the default), wrap_text('') produces an empty string, so no usage line is printed at all. Fixed by adding an early return that writes the prefix + prog directly when args is empty. Fixes #3360 --- src/click/formatting.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/click/formatting.py b/src/click/formatting.py index de2ca47117..2f0dda47a3 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)