diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index 0ab93ca236e7..717596e05c9b 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -4,6 +4,7 @@ use std::path::PathBuf; use std::str::FromStr; use anyhow::{anyhow, Result}; +use clap::builder::styling::Style; use clap::{Args, Parser, Subcommand}; use distribution_types::{FlatIndexLocation, IndexUrl}; @@ -246,10 +247,20 @@ pub enum Commands { #[command(alias = "--generate-shell-completion", hide = true)] GenerateShellCompletion { shell: clap_complete_command::Shell }, /// Display documentation for a command. + // To avoid showing the global options when displaying help for the help command, we are + // responsible for maintaining the options using the `after_help`. #[command(help_template = "\ {about-with-newline} -{usage-heading} {usage} -")] +{usage-heading} {usage}{after-help} +", + after_help = format!("\ +{heading}Options:{heading:#} + {option}--no-pager{option:#} Disable pager when printing help +", + heading = Style::new().bold().underline(), + option = Style::new().bold(), + ), + )] Help(HelpArgs), } diff --git a/crates/uv/tests/help.rs b/crates/uv/tests/help.rs index 123e7a05b431..86a44f913a39 100644 --- a/crates/uv/tests/help.rs +++ b/crates/uv/tests/help.rs @@ -678,6 +678,9 @@ fn help_with_help() { Usage: uv help [OPTIONS] [COMMAND]... + Options: + --no-pager Disable pager when printing help + ----- stderr ----- "###); }