[ty] Add --no-progress option (#21063)

This commit is contained in:
Micha Reiser 2025-10-24 18:00:00 +02:00 committed by GitHub
parent a2d0d39853
commit eb8c0ad87c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 8 deletions

2
crates/ty/docs/cli.md generated
View file

@ -58,6 +58,8 @@ over all configuration files.</p>
<p>This is an advanced option that should usually only be used for first-party or third-party modules that are not installed into your Python environment in a conventional way. Use <code>--python</code> to point ty to your Python environment if it is in an unusual location.</p>
</dd><dt id="ty-check--help"><a href="#ty-check--help"><code>--help</code></a>, <code>-h</code></dt><dd><p>Print help (see a summary with '-h')</p>
</dd><dt id="ty-check--ignore"><a href="#ty-check--ignore"><code>--ignore</code></a> <i>rule</i></dt><dd><p>Disables the rule. Can be specified multiple times.</p>
</dd><dt id="ty-check--no-progress"><a href="#ty-check--no-progress"><code>--no-progress</code></a></dt><dd><p>Hide all progress outputs.</p>
<p>For example, spinners or progress bars.</p>
</dd><dt id="ty-check--output-format"><a href="#ty-check--output-format"><code>--output-format</code></a> <i>output-format</i></dt><dd><p>The format to use for printing diagnostic messages</p>
<p>Possible values:</p>
<ul>

View file

@ -34,6 +34,7 @@ pub(crate) enum Command {
}
#[derive(Debug, Parser)]
#[expect(clippy::struct_excessive_bools)]
pub(crate) struct CheckCommand {
/// List of files or directories to check.
#[clap(
@ -117,10 +118,6 @@ pub(crate) struct CheckCommand {
#[arg(long)]
pub(crate) output_format: Option<OutputFormat>,
/// Control when colored output is used.
#[arg(long, value_name = "WHEN")]
pub(crate) color: Option<TerminalColor>,
/// Use exit code 1 if there are any warning-level diagnostics.
#[arg(long, conflicts_with = "exit_zero", default_missing_value = "true", num_args=0..1)]
pub(crate) error_on_warning: Option<bool>,
@ -152,6 +149,21 @@ pub(crate) struct CheckCommand {
/// Supports patterns like `tests/`, `*.tmp`, `**/__pycache__/**`.
#[arg(long, help_heading = "File selection")]
exclude: Option<Vec<String>>,
/// Control when colored output is used.
#[arg(
long,
value_name = "WHEN",
help_heading = "Global options",
display_order = 1000
)]
pub(crate) color: Option<TerminalColor>,
/// Hide all progress outputs.
///
/// For example, spinners or progress bars.
#[arg(global = true, long, value_parser = clap::builder::BoolishValueParser::new(), help_heading = "Global options")]
pub no_progress: bool,
}
impl CheckCommand {

View file

@ -71,7 +71,7 @@ fn run_check(args: CheckCommand) -> anyhow::Result<ExitStatus> {
let verbosity = args.verbosity.level();
let _guard = setup_tracing(verbosity, args.color.unwrap_or_default())?;
let printer = Printer::default().with_verbosity(verbosity);
let printer = Printer::new(verbosity, args.no_progress);
tracing::debug!("Version: {}", version::version());

View file

@ -12,11 +12,10 @@ pub(crate) struct Printer {
}
impl Printer {
#[must_use]
pub(crate) fn with_verbosity(self, verbosity: VerbosityLevel) -> Self {
pub(crate) fn new(verbosity: VerbosityLevel, no_progress: bool) -> Self {
Self {
verbosity,
no_progress: self.no_progress,
no_progress,
}
}