Skip to content

Commit da943f5

Browse files
committed
Allow --help to be any argument
Also dogfoog.
1 parent 409b8e7 commit da943f5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/main.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ it to allow or deny lints, eg.:
136136
#[cfg_attr(feature = "cargo-clippy", allow(needless_lifetimes))]
137137
"#;
138138

139+
#[allow(print_stdout)]
140+
fn show_help() {
141+
println!("{}", CARGO_CLIPPY_HELP);
142+
}
143+
139144
pub fn main() {
140145
use std::env;
141146

@@ -165,12 +170,9 @@ pub fn main() {
165170
if let Some("clippy") = std::env::args().nth(1).as_ref().map(AsRef::as_ref) {
166171
// this arm is executed on the initial call to `cargo clippy`
167172

168-
match std::env::args().nth(2).as_ref().map(AsRef::as_ref) {
169-
Some("--help") | Some("-h") => {
170-
println!("{}", CARGO_CLIPPY_HELP);
171-
return;
172-
}
173-
_ => (),
173+
if std::env::args().any(|a| a == "--help" || a == "-h") {
174+
show_help();
175+
return;
174176
}
175177

176178
let manifest_path_arg = std::env::args().skip(2).find(|val| val.starts_with("--manifest-path="));

0 commit comments

Comments
 (0)