Skip to content

Commit

Permalink
Show help specific options in uv help (#5516)
Browse files Browse the repository at this point in the history
## Summary

Resolves #5221 

## Test Plan

Test case included.
  • Loading branch information
eth3lbert committed Jul 31, 2024
1 parent ef84380 commit 54398fa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 13 additions & 2 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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),
}

Expand Down
3 changes: 3 additions & 0 deletions crates/uv/tests/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,9 @@ fn help_with_help() {
Usage: uv help [OPTIONS] [COMMAND]...
Options:
--no-pager Disable pager when printing help
----- stderr -----
"###);
}
Expand Down

0 comments on commit 54398fa

Please sign in to comment.