|
3 | 3 | #![warn(rust_2018_idioms, unused_lifetimes)] |
4 | 4 |
|
5 | 5 | use clap::{App, Arg, ArgMatches, SubCommand}; |
6 | | -use clippy_dev::{bless, fmt, setup, new_lint, serve, stderr_length_check, update_lints}; |
| 6 | +use clippy_dev::{bless, fmt, new_lint, serve, setup, stderr_length_check, update_lints}; |
7 | 7 | fn main() { |
8 | 8 | let matches = get_clap_config(); |
9 | 9 |
|
@@ -36,7 +36,11 @@ fn main() { |
36 | 36 | ("limit_stderr_length", _) => { |
37 | 37 | stderr_length_check::check(); |
38 | 38 | }, |
39 | | - ("ide_setup", Some(matches)) => setup::intellij::run(matches.value_of("rustc-repo-path")), |
| 39 | + ("setup", Some(sub_command)) => match sub_command.subcommand() { |
| 40 | + ("intellij", Some(matches)) => setup::intellij::run(matches.value_of("rustc-repo-path")), |
| 41 | + ("git-hook", Some(matches)) => setup::git_hook::run(matches.is_present("force-override")), |
| 42 | + _ => {}, |
| 43 | + }, |
40 | 44 | ("serve", Some(matches)) => { |
41 | 45 | let port = matches.value_of("port").unwrap().parse().unwrap(); |
42 | 46 | let lint = matches.value_of("lint"); |
@@ -140,16 +144,31 @@ fn get_clap_config<'a>() -> ArgMatches<'a> { |
140 | 144 | .about("Ensures that stderr files do not grow longer than a certain amount of lines."), |
141 | 145 | ) |
142 | 146 | .subcommand( |
143 | | - SubCommand::with_name("ide_setup") |
144 | | - .about("Alter dependencies so Intellij Rust can find rustc internals") |
145 | | - .arg( |
146 | | - Arg::with_name("rustc-repo-path") |
147 | | - .long("repo-path") |
148 | | - .short("r") |
149 | | - .help("The path to a rustc repo that will be used for setting the dependencies") |
150 | | - .takes_value(true) |
151 | | - .value_name("path") |
152 | | - .required(true), |
| 147 | + SubCommand::with_name("setup") |
| 148 | + .about("Support for setting up your personal development environment") |
| 149 | + .subcommand( |
| 150 | + SubCommand::with_name("intellij") |
| 151 | + .about("Alter dependencies so Intellij Rust can find rustc internals") |
| 152 | + .arg( |
| 153 | + Arg::with_name("rustc-repo-path") |
| 154 | + .long("repo-path") |
| 155 | + .short("r") |
| 156 | + .help("The path to a rustc repo that will be used for setting the dependencies") |
| 157 | + .takes_value(true) |
| 158 | + .value_name("path") |
| 159 | + .required(true), |
| 160 | + ), |
| 161 | + ) |
| 162 | + .subcommand( |
| 163 | + SubCommand::with_name("git-hook") |
| 164 | + .about("Add a pre-commit git hook that formats your code to make it look pretty") |
| 165 | + .arg( |
| 166 | + Arg::with_name("force-override") |
| 167 | + .long("force-override") |
| 168 | + .short("f") |
| 169 | + .help("Forces the override of an existing git pre-commit hook") |
| 170 | + .required(false), |
| 171 | + ), |
153 | 172 | ), |
154 | 173 | ) |
155 | 174 | .subcommand( |
|
0 commit comments