Hide global option in uv generate-shell-completion (#6170)

Resolve #6152 

## Summary

## Test Plan

Execution result of `cargo run generate-shell-completion --help`

```bash
Generate shell completion

Usage: uv generate-shell-completion <SHELL>

Arguments:
  <SHELL>  The shell to generate the completion script for [possible values: bash, elvish, fish, nushell, powershell, zsh]
```

Execution result of `cargo run help generate-shell-completion`

```bash
Generate shell completion

Usage: uv generate-shell-completion <SHELL>

Arguments:
  <SHELL>
          The shell to generate the completion script for
          
          [possible values: bash, elvish, fish, nushell, powershell, zsh]
```
This commit is contained in:
Di-Is 2024-08-18 03:34:34 +09:00 committed by GitHub
parent 0091adfa5b
commit ad8e3a2c32
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 46 additions and 74 deletions

View file

@ -349,7 +349,7 @@ pub enum Commands {
},
/// Generate shell completion
#[command(alias = "--generate-shell-completion", hide = true)]
GenerateShellCompletion { shell: clap_complete_command::Shell },
GenerateShellCompletion(GenerateShellCompletionArgs),
/// 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`.
@ -3037,6 +3037,45 @@ pub struct PythonPinArgs {
pub no_workspace: bool,
}
#[derive(Args)]
#[allow(clippy::struct_excessive_bools)]
pub struct GenerateShellCompletionArgs {
/// The shell to generate the completion script for
pub shell: clap_complete_command::Shell,
// Hide unused global options.
#[arg(long, short, hide = true)]
pub no_cache: bool,
#[arg(long, hide = true)]
pub cache_dir: Option<PathBuf>,
#[arg(long, hide = true)]
pub python_preference: Option<PythonPreference>,
#[arg(long, hide = true)]
pub no_python_downloads: bool,
#[arg(long, short, conflicts_with = "verbose", hide = true)]
pub quiet: bool,
#[arg(long, short, action = clap::ArgAction::Count, conflicts_with = "quiet", hide = true)]
pub verbose: u8,
#[arg(long, default_value = "auto", conflicts_with = "no_color", hide = true)]
pub color: ColorChoice,
#[arg(long, hide = true)]
pub native_tls: bool,
#[arg(long, hide = true)]
pub offline: bool,
#[arg(long, hide = true)]
pub no_progress: bool,
#[arg(long, hide = true)]
pub config_file: Option<PathBuf>,
#[arg(long, hide = true)]
pub no_config: bool,
#[arg(long, short, action = clap::ArgAction::HelpShort, hide = true)]
pub help: Option<bool>,
#[arg(short = 'V', long, hide = true)]
pub version: bool,
}
#[derive(Args)]
#[allow(clippy::struct_excessive_bools)]
pub struct IndexArgs {