Skip to content

Commit

Permalink
feat: --no-progress to disable all progress bars (#1105)
Browse files Browse the repository at this point in the history
Co-authored-by: Ruben Arts <ruben.arts@hotmail.com>
  • Loading branch information
baszalmstra and ruben-arts authored Apr 3, 2024
1 parent 1f88603 commit ef13371
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ description: All pixi cli subcommands
- `--color <COLOR>`: Whether the log needs to be colored [env: `PIXI_COLOR=`] [default: `auto`] [possible values: always, never, auto].
Pixi also honor the `FORCE_COLOR` and `NO_COLOR` environment variables.
They both take precedence over `--color` and `PIXI_COLOR`.
- `--no-progress`: Disables the progress bar.[env: `PIXI_NO_PROGRESS`] [default: `false`]


## `init`
Expand Down
11 changes: 11 additions & 0 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use super::util::IndicatifWriter;
use crate::progress;
use crate::progress::global_multi_progress;
use clap::Parser;
use clap_complete;
use clap_verbosity_flag::Verbosity;
use indicatif::ProgressDrawTarget;
use miette::IntoDiagnostic;
use std::{env, io::IsTerminal};
use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt;
Expand Down Expand Up @@ -41,6 +43,10 @@ struct Args {
/// Whether the log needs to be colored.
#[clap(long, default_value = "auto", global = true, env = "PIXI_COLOR")]
color: ColorOutput,

/// Hide all progress bars
#[clap(long, default_value = "false", global = true, env = "PIXI_NO_PROGRESS")]
no_progress: bool,
}

/// Generates a completion script for a shell.
Expand Down Expand Up @@ -130,6 +136,11 @@ pub async fn execute() -> miette::Result<()> {
console::set_colors_enabled(use_colors);
console::set_colors_enabled_stderr(use_colors);

// Hide all progress bars if the user requested it.
if args.no_progress {
global_multi_progress().set_draw_target(ProgressDrawTarget::hidden());
}

let (low_level_filter, level_filter, pixi_level) = match args.verbose.log_level_filter() {
clap_verbosity_flag::LevelFilter::Off => {
(LevelFilter::OFF, LevelFilter::OFF, LevelFilter::OFF)
Expand Down

0 comments on commit ef13371

Please sign in to comment.