Skip to content

Commit

Permalink
feat: add environment variable to disable progress output
Browse files Browse the repository at this point in the history
The changes in this commit add a new environment variable `UV_NO_PROGRESS` that allows users to disable progress output, such as spinners and progress bars, in the uv-cli tool. This feature is useful for users who prefer a more minimal or non-interactive output, or for use in environments where progress output may not be desirable or supported.

The changes include:

- Adding the `UV_NO_PROGRESS` environment variable to the `EnvVars` struct in `crates/uv-static/src/env_vars.rs`.
- Updating the `GlobalArgs` struct in `crates/uv-cli/src/lib.rs` to include a new `no_progress` field that is bound to the `UV_NO_PROGRESS` environment variable.
- Adding documentation for the new `UV_NO_PROGRESS` environment variable in `docs/configuration/environment.md`.
  • Loading branch information
zzztimbo committed Oct 26, 2024
1 parent f23d9c1 commit 6cee19f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ pub struct GlobalArgs {
/// Hide all progress outputs.
///
/// For example, spinners or progress bars.
#[arg(global = true, long)]
#[arg(global = true, long, env = EnvVars::UV_NO_PROGRESS, value_parser = clap::builder::BoolishValueParser::new(), overrides_with("no_progress"))]
pub no_progress: bool,

/// Change to the given directory prior to running the command.
Expand Down
3 changes: 3 additions & 0 deletions crates/uv-static/src/env_vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ impl EnvVars {
/// Disables colored output (takes precedence over `FORCE_COLOR`).
pub const NO_COLOR: &'static str = "NO_COLOR";

/// Disables all progress output. For example, spinners and progress bars.
pub const UV_NO_PROGRESS: &'static str = "UV_NO_PROGRESS";

/// Forces colored output regardless of terminal support.
pub const FORCE_COLOR: &'static str = "FORCE_COLOR";

Expand Down
8 changes: 5 additions & 3 deletions crates/uv/tests/it/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn help() {
--native-tls Whether to load TLS certificates from the platform's native
certificate store [env: UV_NATIVE_TLS=]
--offline Disable network access
--no-progress Hide all progress outputs
--no-progress Hide all progress outputs [env: UV_NO_PROGRESS=]
--directory <DIRECTORY> Change to the given directory prior to running the command
--project <PROJECT> Run the command within the given project directory
--config-file <CONFIG_FILE> The path to a `uv.toml` file to use for configuration [env:
Expand Down Expand Up @@ -123,7 +123,7 @@ fn help_flag() {
--native-tls Whether to load TLS certificates from the platform's native
certificate store [env: UV_NATIVE_TLS=]
--offline Disable network access
--no-progress Hide all progress outputs
--no-progress Hide all progress outputs [env: UV_NO_PROGRESS=]
--directory <DIRECTORY> Change to the given directory prior to running the command
--project <PROJECT> Run the command within the given project directory
--config-file <CONFIG_FILE> The path to a `uv.toml` file to use for configuration [env:
Expand Down Expand Up @@ -515,6 +515,8 @@ fn help_subsubcommand() {
For example, spinners or progress bars.
[env: UV_NO_PROGRESS=]
--directory <DIRECTORY>
Change to the given directory prior to running the command.
Expand Down Expand Up @@ -603,7 +605,7 @@ fn help_flag_subcommand() {
--native-tls Whether to load TLS certificates from the platform's native
certificate store [env: UV_NATIVE_TLS=]
--offline Disable network access
--no-progress Hide all progress outputs
--no-progress Hide all progress outputs [env: UV_NO_PROGRESS=]
--directory <DIRECTORY> Change to the given directory prior to running the command
--project <PROJECT> Run the command within the given project directory
--config-file <CONFIG_FILE> The path to a `uv.toml` file to use for configuration [env:
Expand Down
1 change: 1 addition & 0 deletions docs/configuration/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,6 @@ In addition, uv respects the following environment variables:
least-recent non-EOL macOS version at time of writing.
- `NO_COLOR`: Disable colors. Takes precedence over `FORCE_COLOR`. See
[no-color.org](https://no-color.org).
- `UV_NO_PROGRESS`: Disable progress indicators like spinners and progress bars.
- `FORCE_COLOR`: Enforce colors regardless of TTY support. See
[force-color.org](https://force-color.org).
Loading

0 comments on commit 6cee19f

Please sign in to comment.