Skip to content

Commit eb8c0ad

Browse files
authored
[ty] Add --no-progress option (#21063)
1 parent a2d0d39 commit eb8c0ad

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

crates/ty/docs/cli.md

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ty/src/args.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub(crate) enum Command {
3434
}
3535

3636
#[derive(Debug, Parser)]
37+
#[expect(clippy::struct_excessive_bools)]
3738
pub(crate) struct CheckCommand {
3839
/// List of files or directories to check.
3940
#[clap(
@@ -117,10 +118,6 @@ pub(crate) struct CheckCommand {
117118
#[arg(long)]
118119
pub(crate) output_format: Option<OutputFormat>,
119120

120-
/// Control when colored output is used.
121-
#[arg(long, value_name = "WHEN")]
122-
pub(crate) color: Option<TerminalColor>,
123-
124121
/// Use exit code 1 if there are any warning-level diagnostics.
125122
#[arg(long, conflicts_with = "exit_zero", default_missing_value = "true", num_args=0..1)]
126123
pub(crate) error_on_warning: Option<bool>,
@@ -152,6 +149,21 @@ pub(crate) struct CheckCommand {
152149
/// Supports patterns like `tests/`, `*.tmp`, `**/__pycache__/**`.
153150
#[arg(long, help_heading = "File selection")]
154151
exclude: Option<Vec<String>>,
152+
153+
/// Control when colored output is used.
154+
#[arg(
155+
long,
156+
value_name = "WHEN",
157+
help_heading = "Global options",
158+
display_order = 1000
159+
)]
160+
pub(crate) color: Option<TerminalColor>,
161+
162+
/// Hide all progress outputs.
163+
///
164+
/// For example, spinners or progress bars.
165+
#[arg(global = true, long, value_parser = clap::builder::BoolishValueParser::new(), help_heading = "Global options")]
166+
pub no_progress: bool,
155167
}
156168

157169
impl CheckCommand {

crates/ty/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn run_check(args: CheckCommand) -> anyhow::Result<ExitStatus> {
7171
let verbosity = args.verbosity.level();
7272
let _guard = setup_tracing(verbosity, args.color.unwrap_or_default())?;
7373

74-
let printer = Printer::default().with_verbosity(verbosity);
74+
let printer = Printer::new(verbosity, args.no_progress);
7575

7676
tracing::debug!("Version: {}", version::version());
7777

crates/ty/src/printer.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ pub(crate) struct Printer {
1212
}
1313

1414
impl Printer {
15-
#[must_use]
16-
pub(crate) fn with_verbosity(self, verbosity: VerbosityLevel) -> Self {
15+
pub(crate) fn new(verbosity: VerbosityLevel, no_progress: bool) -> Self {
1716
Self {
1817
verbosity,
19-
no_progress: self.no_progress,
18+
no_progress,
2019
}
2120
}
2221

0 commit comments

Comments
 (0)