Skip to content

Commit

Permalink
feat: add a list subcommand to show available linters
Browse files Browse the repository at this point in the history
  • Loading branch information
suo committed Feb 9, 2024
1 parent 53c4961 commit 0765237
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ struct Args {
#[clap(long, short, conflicts_with_all=&["paths", "paths-cmd", "paths-from", "revision"], global = true)]
merge_base_with: Option<String>,

/// 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<String>,

/// 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<String>,

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -313,6 +320,13 @@ fn do_main() -> Result<i32> {
)
}
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 {
Expand Down

0 comments on commit 0765237

Please sign in to comment.