Tweak some wording in CLI help (#2285)

This commit is contained in:
Charlie Marsh 2023-01-27 20:25:58 -05:00 committed by GitHub
parent eda2be6350
commit 249cf73d4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 14 deletions

View file

@ -16,7 +16,7 @@ use rustc_hash::FxHashMap;
author, author,
name = "ruff", name = "ruff",
about = "Ruff: An extremely fast Python linter.", about = "Ruff: An extremely fast Python linter.",
after_help = "To get help about a specific command, see 'ruff help <command>'." after_help = "For help with a specific command, see: `ruff help <command>`."
)] )]
#[command(version)] #[command(version)]
pub struct Args { pub struct Args {
@ -29,8 +29,7 @@ pub struct Args {
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
#[derive(Debug, clap::Subcommand)] #[derive(Debug, clap::Subcommand)]
pub enum Command { pub enum Command {
/// Run ruff on the given files or directories (this command is used by /// Run Ruff on the given files or directories (default).
/// default and may be omitted)
Check(CheckArgs), Check(CheckArgs),
/// Explain a rule. /// Explain a rule.
#[clap(alias = "--explain")] #[clap(alias = "--explain")]
@ -42,10 +41,10 @@ pub enum Command {
#[arg(long, value_enum, env = "RUFF_FORMAT", default_value = "text")] #[arg(long, value_enum, env = "RUFF_FORMAT", default_value = "text")]
format: HelpFormat, 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")] #[clap(alias = "--clean")]
Clean, Clean,
/// Generate shell completion /// Generate shell completion.
#[clap(alias = "--generate-shell-completion", hide = true)] #[clap(alias = "--generate-shell-completion", hide = true)]
GenerateShellCompletion { shell: clap_complete_command::Shell }, GenerateShellCompletion { shell: clap_complete_command::Shell },
} }
@ -53,6 +52,7 @@ pub enum Command {
#[derive(Debug, clap::Args)] #[derive(Debug, clap::Args)]
#[allow(clippy::struct_excessive_bools, clippy::module_name_repetitions)] #[allow(clippy::struct_excessive_bools, clippy::module_name_repetitions)]
pub struct CheckArgs { pub struct CheckArgs {
/// List of files or directories to check.
pub files: Vec<PathBuf>, pub files: Vec<PathBuf>,
/// Attempt to automatically fix lint violations. /// Attempt to automatically fix lint violations.
#[arg(long, overrides_with("no_fix"))] #[arg(long, overrides_with("no_fix"))]

View file

@ -39,18 +39,18 @@ fn inner_main() -> Result<ExitCode> {
// Clap doesn't support default subcommands but we want to run `check` by // Clap doesn't support default subcommands but we want to run `check` by
// default for convenience and backwards-compatibility, so we just // default for convenience and backwards-compatibility, so we just
// preprocess the arguments accordingly before passing them to clap. // preprocess the arguments accordingly before passing them to Clap.
if let Some(arg1) = args.get(1).and_then(|s| s.to_str()) { if let Some(arg) = args.get(1).and_then(|s| s.to_str()) {
if !Command::has_subcommand(arg1) if !Command::has_subcommand(arg)
&& !arg1 && !arg
.strip_prefix("--") .strip_prefix("--")
.map(Command::has_subcommand) .map(Command::has_subcommand)
.unwrap_or_default() .unwrap_or_default()
&& arg1 != "-h" && arg != "-h"
&& arg1 != "--help" && arg != "--help"
&& arg1 != "-v" && arg != "-v"
&& arg1 != "--version" && arg != "--version"
&& arg1 != "help" && arg != "help"
{ {
args.insert(1, "check".into()); args.insert(1, "check".into());
} }