1 #![cfg_attr(feature = "deny-warnings", deny(warnings))]
3 use clap::{App, Arg, SubCommand};
4 use clippy_dev::{fmt, new_lint, ra_setup, serve, stderr_length_check, update_lints};
7 let matches = App::new("Clippy developer tooling")
9 SubCommand::with_name("fmt")
10 .about("Run rustfmt on all projects and tests")
12 Arg::with_name("check")
14 .help("Use the rustfmt --check option"),
17 Arg::with_name("verbose")
20 .help("Echo commands run"),
24 SubCommand::with_name("update_lints")
25 .about("Updates lint registration and information from the source code")
28 * the lint count in README.md is correct\n \
29 * the changelog contains markdown link references at the bottom\n \
30 * all lint groups include the correct lints\n \
31 * lint modules in `clippy_lints/*` are visible in `src/lib.rs` via `pub mod`\n \
32 * all lints are registered in the lint store",
34 .arg(Arg::with_name("print-only").long("print-only").help(
35 "Print a table of lints to STDOUT. \
36 This does not include deprecated and internal lints. \
37 (Does not modify any files)",
40 Arg::with_name("check")
42 .help("Checks that `cargo dev update_lints` has been run. Used on CI."),
46 SubCommand::with_name("new_lint")
47 .about("Create new lint and run `cargo dev update_lints`")
49 Arg::with_name("pass")
52 .help("Specify whether the lint runs during the early or late pass")
54 .possible_values(&["early", "late"])
58 Arg::with_name("name")
61 .help("Name of the new lint in snake case, ex: fn_too_long")
66 Arg::with_name("category")
69 .help("What category the lint belongs to")
70 .default_value("nursery")
87 SubCommand::with_name("limit_stderr_length")
88 .about("Ensures that stderr files do not grow longer than a certain amount of lines."),
91 SubCommand::with_name("ra-setup")
92 .about("Alter dependencies so rust-analyzer can find rustc internals")
94 Arg::with_name("rustc-repo-path")
97 .help("The path to a rustc repo that will be used for setting the dependencies")
104 SubCommand::with_name("serve")
105 .about("Launch a local 'ALL the Clippy Lints' website in a browser")
107 Arg::with_name("port")
110 .help("Local port for the http server")
111 .default_value("8000")
112 .validator_os(serve::validate_port),
114 .arg(Arg::with_name("lint").help("Which lint's page to load initially (optional)")),
118 match matches.subcommand() {
119 ("fmt", Some(matches)) => {
120 fmt::run(matches.is_present("check"), matches.is_present("verbose"));
122 ("update_lints", Some(matches)) => {
123 if matches.is_present("print-only") {
124 update_lints::print_lints();
125 } else if matches.is_present("check") {
126 update_lints::run(update_lints::UpdateMode::Check);
128 update_lints::run(update_lints::UpdateMode::Change);
131 ("new_lint", Some(matches)) => {
132 match new_lint::create(
133 matches.value_of("pass"),
134 matches.value_of("name"),
135 matches.value_of("category"),
137 Ok(_) => update_lints::run(update_lints::UpdateMode::Change),
138 Err(e) => eprintln!("Unable to create lint: {}", e),
141 ("limit_stderr_length", _) => {
142 stderr_length_check::check();
144 ("ra-setup", Some(matches)) => ra_setup::run(matches.value_of("rustc-repo-path")),
145 ("serve", Some(matches)) => {
146 let port = matches.value_of("port").unwrap().parse().unwrap();
147 let lint = matches.value_of("lint");
148 serve::run(port, lint);