From e2ec62cf332b5441921e9d7be82d927caa9ea4a8 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 28 Sep 2022 22:15:58 -0400 Subject: [PATCH] Misc. follow-up changes to #272 (#278) --- README.md | 93 ++++++++++++++++++++-------------------- examples/print_ast.rs | 4 +- examples/print_tokens.rs | 4 +- src/main.rs | 43 +++++++++---------- 4 files changed, 71 insertions(+), 73 deletions(-) diff --git a/README.md b/README.md index 879ef1cda2..e293403cd9 100644 --- a/README.md +++ b/README.md @@ -80,61 +80,60 @@ select = [ Alternatively, on the command-line: ```shell -ruff path/to/code/ --select F401 F403 +ruff path/to/code/ --select F401 --select F403 ``` See `ruff --help` for more: ```shell -ruff (v0.0.46) -An extremely fast Python linter. +ruff: An extremely fast Python linter. -USAGE: - ruff [OPTIONS] ... +Usage: ruff [OPTIONS] ... -ARGS: - ... +Arguments: + ... -OPTIONS: - --select + List of error codes to enable + --extend-select + Like --select, but adds additional error codes on top of the selected ones + --ignore + List of error codes to ignore + --extend-ignore + Like --ignore, but adds additional error codes on top of the ignored ones + --exclude + List of paths, used to exclude files and/or directories from checks + --extend-exclude + Like --exclude, but adds additional files and directories on top of the excluded ones + --per-file-ignores + List of mappings from file pattern to code to exclude + --format + Output serialization format for error messages [default: text] [possible values: text, json] + --show-files + See the files ruff will be run against with the current settings + --show-settings + See ruff's settings + --add-noqa + Enable automatic additions of noqa directives to failing lines + --dummy-variable-rgx + Regular expression matching the name of dummy variables + -h, --help + Print help information + -V, --version + Print version information ``` ### Excluding files diff --git a/examples/print_ast.rs b/examples/print_ast.rs index 45d96b542b..5d88006648 100644 --- a/examples/print_ast.rs +++ b/examples/print_ast.rs @@ -2,14 +2,14 @@ use std::path::PathBuf; use anyhow::Result; -use clap::{Parser, ValueHint}; +use clap::Parser; use rustpython_parser::parser; use ruff::fs; #[derive(Debug, Parser)] struct Cli { - #[arg(value_hint = ValueHint::FilePath, required = true)] + #[arg(required = true)] file: PathBuf, } diff --git a/examples/print_tokens.rs b/examples/print_tokens.rs index 1266ae45de..5733a998c0 100644 --- a/examples/print_tokens.rs +++ b/examples/print_tokens.rs @@ -2,14 +2,14 @@ use std::path::PathBuf; use anyhow::Result; -use clap::{Parser, ValueHint}; +use clap::Parser; use rustpython_parser::lexer; use ruff::fs; #[derive(Debug, Parser)] struct Cli { - #[arg(value_hint = ValueHint::FilePath, required = true)] + #[arg(required = true)] file: PathBuf, } diff --git a/src/main.rs b/src/main.rs index 43f45ce332..751c424bfd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,5 @@ extern crate core; -use regex::Regex; use std::io; use std::path::{Path, PathBuf}; use std::process::ExitCode; @@ -8,11 +7,12 @@ use std::sync::mpsc::channel; use std::time::Instant; use anyhow::Result; -use clap::{Parser, ValueHint}; +use clap::{command, Parser}; use colored::Colorize; use log::{debug, error}; use notify::{raw_watcher, RecursiveMode, Watcher}; use rayon::prelude::*; +use regex::Regex; use walkdir::DirEntry; use ::ruff::cache; @@ -32,62 +32,61 @@ const CARGO_PKG_NAME: &str = env!("CARGO_PKG_NAME"); const CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); #[derive(Debug, Parser)] -#[clap(name = CARGO_PKG_NAME)] -#[clap(about = "An extremely fast Python linter.", long_about = None)] -#[clap(version)] +#[command(author, about = "ruff: An extremely fast Python linter.")] +#[command(version)] struct Cli { - #[arg(value_hint = ValueHint::AnyPath, required = true)] + #[arg(required = true)] files: Vec, /// Enable verbose logging. - #[arg(short, long, action)] + #[arg(short, long)] verbose: bool, /// Disable all logging (but still exit with status code "1" upon detecting errors). - #[arg(short, long, action)] + #[arg(short, long)] quiet: bool, /// Exit with status code "0", even upon detecting errors. - #[arg(short, long, action)] + #[arg(short, long)] exit_zero: bool, /// Run in watch mode by re-running whenever files change. - #[arg(short, long, action)] + #[arg(short, long)] watch: bool, /// Attempt to automatically fix lint errors. - #[arg(short, long, action)] + #[arg(short, long)] fix: bool, /// Disable cache reads. - #[arg(short, long, action)] + #[arg(short, long)] no_cache: bool, /// List of error codes to enable. - #[arg(long, num_args = 1..)] + #[arg(long, value_delimiter = ',')] select: Vec, /// Like --select, but adds additional error codes on top of the selected ones. - #[arg(long, num_args = 1..)] + #[arg(long, value_delimiter = ',')] extend_select: Vec, /// List of error codes to ignore. - #[arg(long, num_args = 1..)] + #[arg(long, value_delimiter = ',')] ignore: Vec, /// Like --ignore, but adds additional error codes on top of the ignored ones. - #[arg(long, num_args = 1..)] + #[arg(long, value_delimiter = ',')] extend_ignore: Vec, /// List of paths, used to exclude files and/or directories from checks. - #[arg(long, num_args = 1..)] + #[arg(long, value_delimiter = ',')] exclude: Vec, /// Like --exclude, but adds additional files and directories on top of the excluded ones. - #[arg(long, num_args = 1..)] + #[arg(long, value_delimiter = ',')] extend_exclude: Vec, /// List of mappings from file pattern to code to exclude - #[arg(long, num_args = 1..)] + #[arg(long, value_delimiter = ',')] per_file_ignores: Vec, /// Output serialization format for error messages. #[arg(long, value_enum, default_value_t=SerializationFormat::Text)] format: SerializationFormat, /// See the files ruff will be run against with the current settings. - #[arg(long, action)] + #[arg(long)] show_files: bool, /// See ruff's settings. - #[arg(long, action)] + #[arg(long)] show_settings: bool, /// Enable automatic additions of noqa directives to failing lines. - #[arg(long, action)] + #[arg(long)] add_noqa: bool, /// Regular expression matching the name of dummy variables. #[arg(long)]