From 249cf73d4e0a70a21c127563a998bb41e08fe8dc Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 27 Jan 2023 20:25:58 -0500 Subject: [PATCH] Tweak some wording in CLI help (#2285) --- ruff_cli/src/args.rs | 10 +++++----- ruff_cli/src/main.rs | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ruff_cli/src/args.rs b/ruff_cli/src/args.rs index 23ea2daf29..b43899b44f 100644 --- a/ruff_cli/src/args.rs +++ b/ruff_cli/src/args.rs @@ -16,7 +16,7 @@ use rustc_hash::FxHashMap; author, name = "ruff", about = "Ruff: An extremely fast Python linter.", - after_help = "To get help about a specific command, see 'ruff help '." + after_help = "For help with a specific command, see: `ruff help `." )] #[command(version)] pub struct Args { @@ -29,8 +29,7 @@ pub struct Args { #[allow(clippy::large_enum_variant)] #[derive(Debug, clap::Subcommand)] pub enum Command { - /// Run ruff on the given files or directories (this command is used by - /// default and may be omitted) + /// Run Ruff on the given files or directories (default). Check(CheckArgs), /// Explain a rule. #[clap(alias = "--explain")] @@ -42,10 +41,10 @@ pub enum Command { #[arg(long, value_enum, env = "RUFF_FORMAT", default_value = "text")] format: HelpFormat, }, - /// Clear any caches in the current directory or any subdirectories. + /// Clear any caches in the current directory and any subdirectories. #[clap(alias = "--clean")] Clean, - /// Generate shell completion + /// Generate shell completion. #[clap(alias = "--generate-shell-completion", hide = true)] GenerateShellCompletion { shell: clap_complete_command::Shell }, } @@ -53,6 +52,7 @@ pub enum Command { #[derive(Debug, clap::Args)] #[allow(clippy::struct_excessive_bools, clippy::module_name_repetitions)] pub struct CheckArgs { + /// List of files or directories to check. pub files: Vec, /// Attempt to automatically fix lint violations. #[arg(long, overrides_with("no_fix"))] diff --git a/ruff_cli/src/main.rs b/ruff_cli/src/main.rs index d55f4189ed..b5140fce4a 100644 --- a/ruff_cli/src/main.rs +++ b/ruff_cli/src/main.rs @@ -39,18 +39,18 @@ fn inner_main() -> Result { // Clap doesn't support default subcommands but we want to run `check` by // default for convenience and backwards-compatibility, so we just - // preprocess the arguments accordingly before passing them to clap. - if let Some(arg1) = args.get(1).and_then(|s| s.to_str()) { - if !Command::has_subcommand(arg1) - && !arg1 + // preprocess the arguments accordingly before passing them to Clap. + if let Some(arg) = args.get(1).and_then(|s| s.to_str()) { + if !Command::has_subcommand(arg) + && !arg .strip_prefix("--") .map(Command::has_subcommand) .unwrap_or_default() - && arg1 != "-h" - && arg1 != "--help" - && arg1 != "-v" - && arg1 != "--version" - && arg1 != "help" + && arg != "-h" + && arg != "--help" + && arg != "-v" + && arg != "--version" + && arg != "help" { args.insert(1, "check".into()); }