Skip to content

Commit 0765237

Browse files
committed
feat: add a list subcommand to show available linters
1 parent 53c4961 commit 0765237

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/main.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,15 @@ struct Args {
6767
#[clap(long, short, conflicts_with_all=&["paths", "paths-cmd", "paths-from", "revision"], global = true)]
6868
merge_base_with: Option<String>,
6969

70-
/// Comma-separated list of linters to skip (e.g. --skip CLANGFORMAT,NOQA)
70+
/// Comma-separated list of linters to skip (e.g. --skip CLANGFORMAT,NOQA).
71+
///
72+
/// You can run: `lintrunner list` to see available linters.
7173
#[clap(long, global = true)]
7274
skip: Option<String>,
7375

74-
/// Comma-separated list of linters to run (opposite of --skip)
76+
/// Comma-separated list of linters to run (opposite of --skip).
77+
///
78+
/// You can run: `lintrunner list` to see available linters.
7579
#[clap(long, global = true)]
7680
take: Option<String>,
7781

@@ -129,6 +133,9 @@ enum SubCommand {
129133
/// Run linters. This is the default if no subcommand is provided.
130134
Lint,
131135

136+
/// Show the list of available linters, based on this repo's .lintrunner.toml.
137+
List,
138+
132139
/// Create a bug report for a past invocation of lintrunner.
133140
Rage {
134141
/// Choose a specific invocation to report on. 0 is the most recent run.
@@ -313,6 +320,13 @@ fn do_main() -> Result<i32> {
313320
)
314321
}
315322
SubCommand::Rage { invocation } => do_rage(&persistent_data_store, invocation),
323+
SubCommand::List => {
324+
println!("Available linters:");
325+
for linter in &lint_runner_config.linters {
326+
println!(" {}", linter.code);
327+
}
328+
Ok(0)
329+
}
316330
};
317331

318332
let exit_info = match &res {

0 commit comments

Comments
 (0)