mirror of https://github.com/astral-sh/uv
Show help specific options in `uv help` (#5516)
## Summary Resolves #5221 ## Test Plan Test case included.
This commit is contained in:
parent
ef84380954
commit
54398fa7bc
|
|
@ -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),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -678,6 +678,9 @@ fn help_with_help() {
|
|||
|
||||
Usage: uv help [OPTIONS] [COMMAND]...
|
||||
|
||||
Options:
|
||||
--no-pager Disable pager when printing help
|
||||
|
||||
----- stderr -----
|
||||
"###);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue