Skip to content

[CLI] Pretty-print --help with ANSI styling#4192

Merged
hanouticelina merged 11 commits into
mainfrom
cursor/pretty-help-9c69
May 12, 2026
Merged

[CLI] Pretty-print --help with ANSI styling#4192
hanouticelina merged 11 commits into
mainfrom
cursor/pretty-help-9c69

Conversation

@Wauplin

@Wauplin Wauplin commented May 5, 2026

Copy link
Copy Markdown
Collaborator

Related to private slack thread: https://huggingface.slack.com/archives/C0ACCEFPU9W/p1777986048386859

This PR highlights a bit more the sections and commands in the help section of the CLI.
Mainly:

  • underlined + bold section titles
  • bold options/commands

Also update ANSI helper to never return formatted strings when running in agent mode.

hf --help

image

hf upload --help

image

Slack Thread

Open in Web Open in Cursor 

Note

Low Risk
Low risk: changes are limited to CLI --help formatting and ANSI styling behavior (now disabled in agent/NO_COLOR contexts), with no impact on Hub API calls or data handling.

Overview
Improves hf ... --help readability by introducing a custom Click help formatter that underlines section headings and bolds option/command names, and wiring it in via a new StyledContext used by the main Typer group and generated commands.

Extends the ANSI terminal helper with underline() and ensures ANSI codes are never emitted when NO_COLOR is set or when running under a detected AI agent (is_agent()).

Reviewed by Cursor Bugbot for commit 9504648. Bugbot is set up for automated code reviews on this repo. Configure here.

Add a StyledHelpFormatter that applies ANSI formatting to CLI help:
- Bold section headings (Options:, Commands:, etc.)
- Yellow 'Usage:' prefix with bold program name
- Cyan command/option names in definition lists
- Dim example lines ($ hf ...)
- Bold epilog headings (Examples, Learn more)

ANSI codes are only emitted when stdout is a TTY, the process
is not driven by an AI agent, and NO_COLOR is not set.

Co-authored-by: Lucain <Wauplin@users.noreply.github.com>
@bot-ci-comment

bot-ci-comment Bot commented May 5, 2026

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

cursoragent and others added 3 commits May 5, 2026 15:43
- Replace raw ANSI escape codes with the existing ANSI utility class
- Add ANSI.dim() to the shared helper
- Remove cyan styling from definition list entries
- Fix false-positive bolding of description text (only bold
  epilog headings at indent level 0)

Co-authored-by: Lucain <Wauplin@users.noreply.github.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit dc1ba71. Configure here.

Comment thread src/huggingface_hub/cli/_help_formatter.py Outdated
@Wauplin Wauplin marked this pull request as ready for review May 6, 2026 09:53
@Wauplin Wauplin requested review from hanouticelina and julien-c May 6, 2026 09:53
@julien-c

julien-c commented May 6, 2026

Copy link
Copy Markdown
Member

i like it!!

@hanouticelina hanouticelina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice!

@hanouticelina hanouticelina merged commit 04195e0 into main May 12, 2026
20 checks passed
@hanouticelina hanouticelina deleted the cursor/pretty-help-9c69 branch May 12, 2026 16:23
@huggingface-hub-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped as part of the v1.15.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants