diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index c83ed54f4..16d8f871b 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -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, + + #[arg(long, hide = true)] + pub python_preference: Option, + #[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, + #[arg(long, hide = true)] + pub no_config: bool, + #[arg(long, short, action = clap::ArgAction::HelpShort, hide = true)] + pub help: Option, + #[arg(short = 'V', long, hide = true)] + pub version: bool, +} + #[derive(Args)] #[allow(clippy::struct_excessive_bools)] pub struct IndexArgs { diff --git a/crates/uv/src/lib.rs b/crates/uv/src/lib.rs index 42bebb8ad..080ed988e 100644 --- a/crates/uv/src/lib.rs +++ b/crates/uv/src/lib.rs @@ -723,8 +723,8 @@ async fn run(cli: Cli) -> Result { commands::version(output_format, &mut stdout())?; Ok(ExitStatus::Success) } - Commands::GenerateShellCompletion { shell } => { - shell.generate(&mut Cli::command(), &mut stdout()); + Commands::GenerateShellCompletion(args) => { + args.shell.generate(&mut Cli::command(), &mut stdout()); Ok(ExitStatus::Success) } Commands::Tool(ToolNamespace { diff --git a/docs/reference/cli.md b/docs/reference/cli.md index a45465bfb..a6c1e9d90 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -5709,84 +5709,17 @@ Generate shell completion

Usage

``` -uv generate-shell-completion [OPTIONS] +uv generate-shell-completion ```

Arguments

-
SHELL
- -

Options

- -
--cache-dir cache-dir

Path to the cache directory.

- -

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

- -
--color color-choice

Control colors in output

- -

[default: auto]

-

Possible values:

- -
    -
  • auto: Enables colored output only when the output is going to a terminal or TTY with support
  • - -
  • always: Enables colored output regardless of the detected environment
  • - -
  • never: Disables colored output
  • -
-
--config-file config-file

The path to a uv.toml file to use for configuration.

- -

While uv configuration can be included in a pyproject.toml file, it is not allowed in this context.

- -
--help, -h

Display the concise help for this command

- -
--native-tls

Whether to load TLS certificates from the platform’s native certificate store.

- -

By default, uv loads certificates from the bundled webpki-roots crate. The webpki-roots are a reliable set of trust roots from Mozilla, and including them in uv improves portability and performance (especially on macOS).

- -

However, in some cases, you may want to use the platform’s native certificate store, especially if you’re relying on a corporate trust root (e.g., for a mandatory proxy) that’s included in your system’s certificate store.

- -
--no-cache, -n

Avoid reading from or writing to the cache, instead using a temporary directory for the duration of the operation

- -
--no-config

Avoid discovering configuration files (pyproject.toml, uv.toml).

- -

Normally, configuration files are discovered in the current directory, parent directories, or user configuration directories.

- -
--no-progress

Hide all progress outputs.

- -

For example, spinners or progress bars.

- -
--no-python-downloads

Disable automatic downloads of Python

- -
--offline

Disable network access.

- -

When disabled, uv will only use locally cached data and locally available files.

- -
--python-preference python-preference

Whether to prefer uv-managed or system Python installations.

- -

By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

- -

Possible values:

- -
    -
  • only-managed: Only use managed Python installations; never use system Python installations
  • - -
  • managed: Prefer managed Python installations over system Python installations
  • - -
  • system: Prefer system Python installations over managed Python installations
  • - -
  • only-system: Only use system Python installations; never use managed Python installations
  • -
-
--quiet, -q

Do not print any output

- -
--verbose, -v

Use verbose output.

- -

You can configure fine-grained logging using the RUST_LOG environment variable. (<https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives>)

- -
--version, -V

Display the uv version

+
SHELL

The shell to generate the completion script for

+ + ## uv help Display documentation for a command