Skip to content

Commit deef639

Browse files
committed
feat: add environment variable to disable progress output
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`.
1 parent f23d9c1 commit deef639

File tree

5 files changed

+59
-12
lines changed

5 files changed

+59
-12
lines changed

crates/uv-cli/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ pub struct GlobalArgs {
232232
/// Hide all progress outputs.
233233
///
234234
/// For example, spinners or progress bars.
235-
#[arg(global = true, long)]
235+
#[arg(global = true, long, env = EnvVars::UV_NO_PROGRESS, value_parser = clap::builder::BoolishValueParser::new())]
236236
pub no_progress: bool,
237237

238238
/// Change to the given directory prior to running the command.

crates/uv-static/src/env_vars.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ impl EnvVars {
277277
/// Disables colored output (takes precedence over `FORCE_COLOR`).
278278
pub const NO_COLOR: &'static str = "NO_COLOR";
279279

280+
/// Disables all progress output. For example, spinners and progress bars.
281+
pub const UV_NO_PROGRESS: &'static str = "UV_NO_PROGRESS";
282+
280283
/// Forces colored output regardless of terminal support.
281284
pub const FORCE_COLOR: &'static str = "FORCE_COLOR";
282285

crates/uv/tests/it/help.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn help() {
5454
--native-tls Whether to load TLS certificates from the platform's native
5555
certificate store [env: UV_NATIVE_TLS=]
5656
--offline Disable network access
57-
--no-progress Hide all progress outputs
57+
--no-progress Hide all progress outputs [env: UV_NO_PROGRESS=]
5858
--directory <DIRECTORY> Change to the given directory prior to running the command
5959
--project <PROJECT> Run the command within the given project directory
6060
--config-file <CONFIG_FILE> The path to a `uv.toml` file to use for configuration [env:
@@ -123,7 +123,7 @@ fn help_flag() {
123123
--native-tls Whether to load TLS certificates from the platform's native
124124
certificate store [env: UV_NATIVE_TLS=]
125125
--offline Disable network access
126-
--no-progress Hide all progress outputs
126+
--no-progress Hide all progress outputs [env: UV_NO_PROGRESS=]
127127
--directory <DIRECTORY> Change to the given directory prior to running the command
128128
--project <PROJECT> Run the command within the given project directory
129129
--config-file <CONFIG_FILE> The path to a `uv.toml` file to use for configuration [env:
@@ -191,7 +191,7 @@ fn help_short_flag() {
191191
--native-tls Whether to load TLS certificates from the platform's native
192192
certificate store [env: UV_NATIVE_TLS=]
193193
--offline Disable network access
194-
--no-progress Hide all progress outputs
194+
--no-progress Hide all progress outputs [env: UV_NO_PROGRESS=]
195195
--directory <DIRECTORY> Change to the given directory prior to running the command
196196
--project <PROJECT> Run the command within the given project directory
197197
--config-file <CONFIG_FILE> The path to a `uv.toml` file to use for configuration [env:
@@ -211,7 +211,7 @@ fn help_short_flag() {
211211
fn help_subcommand() {
212212
let context = TestContext::new_with_versions(&[]);
213213

214-
uv_snapshot!(context.filters(), context.help().arg("python"), @r##"
214+
uv_snapshot!(context.filters(), context.help().arg("python"), @r###"
215215
success: true
216216
exit_code: 0
217217
----- stdout -----
@@ -344,6 +344,8 @@ fn help_subcommand() {
344344
Hide all progress outputs.
345345
346346
For example, spinners or progress bars.
347+
348+
[env: UV_NO_PROGRESS=]
347349
348350
--directory <DIRECTORY>
349351
Change to the given directory prior to running the command.
@@ -392,14 +394,14 @@ fn help_subcommand() {
392394
393395
394396
----- stderr -----
395-
"##);
397+
"###);
396398
}
397399

398400
#[test]
399401
fn help_subsubcommand() {
400402
let context = TestContext::new_with_versions(&[]);
401403

402-
uv_snapshot!(context.filters(), context.help().arg("python").arg("install"), @r##"
404+
uv_snapshot!(context.filters(), context.help().arg("python").arg("install"), @r###"
403405
success: true
404406
exit_code: 0
405407
----- stdout -----
@@ -514,6 +516,8 @@ fn help_subsubcommand() {
514516
Hide all progress outputs.
515517
516518
For example, spinners or progress bars.
519+
520+
[env: UV_NO_PROGRESS=]
517521
518522
--directory <DIRECTORY>
519523
Change to the given directory prior to running the command.
@@ -560,7 +564,7 @@ fn help_subsubcommand() {
560564
561565
562566
----- stderr -----
563-
"##);
567+
"###);
564568
}
565569

566570
#[test]
@@ -603,7 +607,7 @@ fn help_flag_subcommand() {
603607
--native-tls Whether to load TLS certificates from the platform's native
604608
certificate store [env: UV_NATIVE_TLS=]
605609
--offline Disable network access
606-
--no-progress Hide all progress outputs
610+
--no-progress Hide all progress outputs [env: UV_NO_PROGRESS=]
607611
--directory <DIRECTORY> Change to the given directory prior to running the command
608612
--project <PROJECT> Run the command within the given project directory
609613
--config-file <CONFIG_FILE> The path to a `uv.toml` file to use for configuration [env:
@@ -657,7 +661,7 @@ fn help_flag_subsubcommand() {
657661
--native-tls Whether to load TLS certificates from the platform's native
658662
certificate store [env: UV_NATIVE_TLS=]
659663
--offline Disable network access
660-
--no-progress Hide all progress outputs
664+
--no-progress Hide all progress outputs [env: UV_NO_PROGRESS=]
661665
--directory <DIRECTORY> Change to the given directory prior to running the command
662666
--project <PROJECT> Run the command within the given project directory
663667
--config-file <CONFIG_FILE> The path to a `uv.toml` file to use for configuration [env:
@@ -803,7 +807,7 @@ fn help_with_global_option() {
803807
--native-tls Whether to load TLS certificates from the platform's native
804808
certificate store [env: UV_NATIVE_TLS=]
805809
--offline Disable network access
806-
--no-progress Hide all progress outputs
810+
--no-progress Hide all progress outputs [env: UV_NO_PROGRESS=]
807811
--directory <DIRECTORY> Change to the given directory prior to running the command
808812
--project <PROJECT> Run the command within the given project directory
809813
--config-file <CONFIG_FILE> The path to a `uv.toml` file to use for configuration [env:
@@ -908,7 +912,7 @@ fn help_with_no_pager() {
908912
--native-tls Whether to load TLS certificates from the platform's native
909913
certificate store [env: UV_NATIVE_TLS=]
910914
--offline Disable network access
911-
--no-progress Hide all progress outputs
915+
--no-progress Hide all progress outputs [env: UV_NO_PROGRESS=]
912916
--directory <DIRECTORY> Change to the given directory prior to running the command
913917
--project <PROJECT> Run the command within the given project directory
914918
--config-file <CONFIG_FILE> The path to a `uv.toml` file to use for configuration [env:

docs/configuration/environment.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,6 @@ In addition, uv respects the following environment variables:
151151
least-recent non-EOL macOS version at time of writing.
152152
- `NO_COLOR`: Disable colors. Takes precedence over `FORCE_COLOR`. See
153153
[no-color.org](https://no-color.org).
154+
- `UV_NO_PROGRESS`: Disable progress indicators like spinners and progress bars.
154155
- `FORCE_COLOR`: Enforce colors regardless of TTY support. See
155156
[force-color.org](https://force-color.org).

0 commit comments

Comments
 (0)