1 #![cfg_attr(feature = "deny-warnings", deny(warnings))]
3 use clap::{App, Arg, SubCommand};
4 use clippy_dev::{bless, fmt, new_lint, ra_setup, serve, stderr_length_check, update_lints};
7 let matches = App::new("Clippy developer tooling")
8 .subcommand(SubCommand::with_name("bless").about("bless the test output changes"))
10 SubCommand::with_name("fmt")
11 .about("Run rustfmt on all projects and tests")
13 Arg::with_name("check")
15 .help("Use the rustfmt --check option"),
18 Arg::with_name("verbose")
21 .help("Echo commands run"),
25 SubCommand::with_name("update_lints")
26 .about("Updates lint registration and information from the source code")
29 * the lint count in README.md is correct\n \
30 * the changelog contains markdown link references at the bottom\n \
31 * all lint groups include the correct lints\n \
32 * lint modules in `clippy_lints/*` are visible in `src/lib.rs` via `pub mod`\n \
33 * all lints are registered in the lint store",
35 .arg(Arg::with_name("print-only").long("print-only").help(
36 "Print a table of lints to STDOUT. \
37 This does not include deprecated and internal lints. \
38 (Does not modify any files)",
41 Arg::with_name("check")
43 .help("Checks that `cargo dev update_lints` has been run. Used on CI."),
47 SubCommand::with_name("new_lint")
48 .about("Create new lint and run `cargo dev update_lints`")
50 Arg::with_name("pass")
53 .help("Specify whether the lint runs during the early or late pass")
55 .possible_values(&["early", "late"])
59 Arg::with_name("name")
62 .help("Name of the new lint in snake case, ex: fn_too_long")
67 Arg::with_name("category")
70 .help("What category the lint belongs to")
71 .default_value("nursery")
88 SubCommand::with_name("limit_stderr_length")
89 .about("Ensures that stderr files do not grow longer than a certain amount of lines."),
92 SubCommand::with_name("ra-setup")
93 .about("Alter dependencies so rust-analyzer can find rustc internals")
95 Arg::with_name("rustc-repo-path")
98 .help("The path to a rustc repo that will be used for setting the dependencies")
105 SubCommand::with_name("serve")
106 .about("Launch a local 'ALL the Clippy Lints' website in a browser")
108 Arg::with_name("port")
111 .help("Local port for the http server")
112 .default_value("8000")
113 .validator_os(serve::validate_port),
115 .arg(Arg::with_name("lint").help("Which lint's page to load initially (optional)")),
119 match matches.subcommand() {
120 ("bless", Some(_)) => {
123 ("fmt", Some(matches)) => {
124 fmt::run(matches.is_present("check"), matches.is_present("verbose"));
126 ("update_lints", Some(matches)) => {
127 if matches.is_present("print-only") {
128 update_lints::print_lints();
129 } else if matches.is_present("check") {
130 update_lints::run(update_lints::UpdateMode::Check);
132 update_lints::run(update_lints::UpdateMode::Change);
135 ("new_lint", Some(matches)) => {
136 match new_lint::create(
137 matches.value_of("pass"),
138 matches.value_of("name"),
139 matches.value_of("category"),
141 Ok(_) => update_lints::run(update_lints::UpdateMode::Change),
142 Err(e) => eprintln!("Unable to create lint: {}", e),
145 ("limit_stderr_length", _) => {
146 stderr_length_check::check();
148 ("ra-setup", Some(matches)) => ra_setup::run(matches.value_of("rustc-repo-path")),
149 ("serve", Some(matches)) => {
150 let port = matches.value_of("port").unwrap().parse().unwrap();
151 let lint = matches.value_of("lint");
152 serve::run(port, lint);