Skip to content

Commit c7e6863

Browse files
committed
Auto merge of #8664 - yoav-lavi:main, r=xFrednet
Allow passing `--remove` to `cargo dev setup <SUBCOMMAND>` changelog: none Allows passing `--remove` to `cargo dev setup <SUBCOMMAND>` as an alternative to `cargo dev remove ...` Fixes #8663
2 parents cfd52aa + ffde78b commit c7e6863

File tree

1 file changed

+44
-7
lines changed

1 file changed

+44
-7
lines changed

clippy_dev/src/main.rs

+44-7
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,31 @@ fn main() {
3636
}
3737
},
3838
("setup", Some(sub_command)) => match sub_command.subcommand() {
39-
("intellij", Some(matches)) => setup::intellij::setup_rustc_src(
40-
matches
41-
.value_of("rustc-repo-path")
42-
.expect("this field is mandatory and therefore always valid"),
43-
),
44-
("git-hook", Some(matches)) => setup::git_hook::install_hook(matches.is_present("force-override")),
45-
("vscode-tasks", Some(matches)) => setup::vscode::install_tasks(matches.is_present("force-override")),
39+
("intellij", Some(matches)) => {
40+
if matches.is_present("remove") {
41+
setup::intellij::remove_rustc_src();
42+
} else {
43+
setup::intellij::setup_rustc_src(
44+
matches
45+
.value_of("rustc-repo-path")
46+
.expect("this field is mandatory and therefore always valid"),
47+
);
48+
}
49+
},
50+
("git-hook", Some(matches)) => {
51+
if matches.is_present("remove") {
52+
setup::git_hook::remove_hook();
53+
} else {
54+
setup::git_hook::install_hook(matches.is_present("force-override"));
55+
}
56+
},
57+
("vscode-tasks", Some(matches)) => {
58+
if matches.is_present("remove") {
59+
setup::vscode::remove_tasks();
60+
} else {
61+
setup::vscode::install_tasks(matches.is_present("force-override"));
62+
}
63+
},
4664
_ => {},
4765
},
4866
("remove", Some(sub_command)) => match sub_command.subcommand() {
@@ -167,19 +185,32 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
167185
.subcommand(
168186
SubCommand::with_name("intellij")
169187
.about("Alter dependencies so Intellij Rust can find rustc internals")
188+
.arg(
189+
Arg::with_name("remove")
190+
.long("remove")
191+
.help("Remove the dependencies added with 'cargo dev setup intellij'")
192+
.required(false),
193+
)
170194
.arg(
171195
Arg::with_name("rustc-repo-path")
172196
.long("repo-path")
173197
.short("r")
174198
.help("The path to a rustc repo that will be used for setting the dependencies")
175199
.takes_value(true)
176200
.value_name("path")
201+
.conflicts_with("remove")
177202
.required(true),
178203
),
179204
)
180205
.subcommand(
181206
SubCommand::with_name("git-hook")
182207
.about("Add a pre-commit git hook that formats your code to make it look pretty")
208+
.arg(
209+
Arg::with_name("remove")
210+
.long("remove")
211+
.help("Remove the pre-commit hook added with 'cargo dev setup git-hook'")
212+
.required(false),
213+
)
183214
.arg(
184215
Arg::with_name("force-override")
185216
.long("force-override")
@@ -191,6 +222,12 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
191222
.subcommand(
192223
SubCommand::with_name("vscode-tasks")
193224
.about("Add several tasks to vscode for formatting, validation and testing")
225+
.arg(
226+
Arg::with_name("remove")
227+
.long("remove")
228+
.help("Remove the tasks added with 'cargo dev setup vscode-tasks'")
229+
.required(false),
230+
)
194231
.arg(
195232
Arg::with_name("force-override")
196233
.long("force-override")

0 commit comments

Comments
 (0)