Skip to content

Empty output from HelpFormatter.write_usage for a program without arguments #3360

@Melebius

Description

@Melebius

If no args are passed to HelpFormatter.write_usage, the Usage line is not printed.

Reproduction

import click

f = click.HelpFormatter()
f.write_usage("program")
print(f.getvalue())

Expected output

Usage: program

Actual output

(an empty line)

Environment

  • Python version: 3.12.3
  • Click version: 8.3.1

Additional information

We use click for a CLI program with interactive mode. We are about to use click.HelpFormatter to print help for internal commands, some of which do not accept any arguments (exit, for example).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions