mirror of
https://github.com/astral-sh/ruff
synced 2026-01-22 05:51:03 -05:00
refactor: Rename CLI arg structs from Cli to Args
Technically the command-line interface (CLI) encompasses both input and output, so naming the input structs 'Args' is more accurate than 'Cli'.
This commit is contained in:
committed by
Charlie Marsh
parent
b346f74915
commit
d9ead4e6df
@@ -19,7 +19,7 @@ use rustc_hash::FxHashMap;
|
||||
)]
|
||||
#[command(version)]
|
||||
#[allow(clippy::struct_excessive_bools)]
|
||||
pub struct Cli {
|
||||
pub struct Args {
|
||||
#[arg(required_unless_present_any = ["clean", "explain", "generate_shell_completion"])]
|
||||
pub files: Vec<PathBuf>,
|
||||
/// Path to the `pyproject.toml` or `ruff.toml` file to use for
|
||||
@@ -231,7 +231,7 @@ pub struct Cli {
|
||||
pub show_settings: bool,
|
||||
}
|
||||
|
||||
impl Cli {
|
||||
impl Args {
|
||||
/// Partition the CLI into command-line arguments and configuration
|
||||
/// overrides.
|
||||
pub fn partition(self) -> (Arguments, Overrides) {
|
||||
@@ -421,12 +421,12 @@ impl ConfigProcessor for &Overrides {
|
||||
}
|
||||
|
||||
/// Map the CLI settings to a `LogLevel`.
|
||||
pub fn extract_log_level(cli: &Arguments) -> LogLevel {
|
||||
if cli.silent {
|
||||
pub fn extract_log_level(args: &Arguments) -> LogLevel {
|
||||
if args.silent {
|
||||
LogLevel::Silent
|
||||
} else if cli.quiet {
|
||||
} else if args.quiet {
|
||||
LogLevel::Quiet
|
||||
} else if cli.verbose {
|
||||
} else if args.verbose {
|
||||
LogLevel::Verbose
|
||||
} else {
|
||||
LogLevel::Default
|
||||
@@ -23,8 +23,8 @@ use ruff::{fix, fs, packaging, resolver, warn_user_once, AutofixAvailability, IO
|
||||
use serde::Serialize;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
use crate::args::Overrides;
|
||||
use crate::cache;
|
||||
use crate::cli::Overrides;
|
||||
use crate::diagnostics::{lint_path, lint_stdin, Diagnostics};
|
||||
use crate::iterators::par_iter;
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
#![warn(clippy::pedantic)]
|
||||
#![allow(clippy::must_use_candidate, dead_code)]
|
||||
|
||||
mod cli;
|
||||
mod args;
|
||||
|
||||
use clap::CommandFactory;
|
||||
|
||||
/// Returns the output of `ruff --help`.
|
||||
pub fn help() -> String {
|
||||
cli::Cli::command().render_help().to_string()
|
||||
args::Args::command().render_help().to_string()
|
||||
}
|
||||
|
||||
@@ -21,16 +21,16 @@ use ::ruff::settings::pyproject;
|
||||
use ::ruff::settings::types::SerializationFormat;
|
||||
use ::ruff::{fix, fs, warn_user_once};
|
||||
use anyhow::Result;
|
||||
use args::{extract_log_level, Args, Overrides};
|
||||
use clap::{CommandFactory, Parser};
|
||||
use cli::{extract_log_level, Cli, Overrides};
|
||||
use colored::Colorize;
|
||||
use notify::{recommended_watcher, RecursiveMode, Watcher};
|
||||
use path_absolutize::path_dedot;
|
||||
use printer::{Printer, Violations};
|
||||
use ruff::settings::{AllSettings, CliSettings};
|
||||
|
||||
mod args;
|
||||
mod cache;
|
||||
mod cli;
|
||||
mod commands;
|
||||
mod diagnostics;
|
||||
mod iterators;
|
||||
@@ -91,7 +91,7 @@ fn resolve(
|
||||
|
||||
fn inner_main() -> Result<ExitCode> {
|
||||
// Extract command-line arguments.
|
||||
let (cli, overrides) = Cli::parse().partition();
|
||||
let (cli, overrides) = Args::parse().partition();
|
||||
|
||||
let default_panic_hook = std::panic::take_hook();
|
||||
std::panic::set_hook(Box::new(move |info| {
|
||||
@@ -112,7 +112,7 @@ quoting the executed command, along with the relevant file contents and `pyproje
|
||||
set_up_logging(&log_level)?;
|
||||
|
||||
if let Some(shell) = cli.generate_shell_completion {
|
||||
shell.generate(&mut Cli::command(), &mut io::stdout());
|
||||
shell.generate(&mut Args::command(), &mut io::stdout());
|
||||
return Ok(ExitCode::SUCCESS);
|
||||
}
|
||||
if cli.clean {
|
||||
|
||||
Reference in New Issue
Block a user