From 0765237900aaa7e0ecb3491227b073fa72216b36 Mon Sep 17 00:00:00 2001 From: Michael Suo Date: Thu, 8 Feb 2024 17:12:22 -0800 Subject: [PATCH] feat: add a list subcommand to show available linters --- src/main.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index d039c29..ff619cf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -67,11 +67,15 @@ struct Args { #[clap(long, short, conflicts_with_all=&["paths", "paths-cmd", "paths-from", "revision"], global = true)] merge_base_with: Option, - /// Comma-separated list of linters to skip (e.g. --skip CLANGFORMAT,NOQA) + /// Comma-separated list of linters to skip (e.g. --skip CLANGFORMAT,NOQA). + /// + /// You can run: `lintrunner list` to see available linters. #[clap(long, global = true)] skip: Option, - /// Comma-separated list of linters to run (opposite of --skip) + /// Comma-separated list of linters to run (opposite of --skip). + /// + /// You can run: `lintrunner list` to see available linters. #[clap(long, global = true)] take: Option, @@ -129,6 +133,9 @@ enum SubCommand { /// Run linters. This is the default if no subcommand is provided. Lint, + /// Show the list of available linters, based on this repo's .lintrunner.toml. + List, + /// Create a bug report for a past invocation of lintrunner. Rage { /// Choose a specific invocation to report on. 0 is the most recent run. @@ -313,6 +320,13 @@ fn do_main() -> Result { ) } SubCommand::Rage { invocation } => do_rage(&persistent_data_store, invocation), + SubCommand::List => { + println!("Available linters:"); + for linter in &lint_runner_config.linters { + println!(" {}", linter.code); + } + Ok(0) + } }; let exit_info = match &res {