Common options:
-h, --help Print this message
--features Features to compile for the package
+ -V, --version Print version info and exit
Other options are the same as `cargo rustc`.
if env::var("CLIPPY_DOGFOOD").map(|_| true).unwrap_or(false) {
panic!("yummy");
}
+
+ // Check for version and help flags even when invoked as 'cargo-clippy'
+ if std::env::args().any(|a| a == "--help" || a == "-h") {
+ show_help();
+ return;
+ }
+ if std::env::args().any(|a| a == "--version" || a == "-V") {
+ println!("{}", env!("CARGO_PKG_VERSION"));
+ return;
+ }
let dep_path = env::current_dir().expect("current dir is not readable").join("target").join("debug").join("deps");
if let Some("clippy") = std::env::args().nth(1).as_ref().map(AsRef::as_ref) {
// this arm is executed on the initial call to `cargo clippy`
- if std::env::args().any(|a| a == "--help" || a == "-h") {
- show_help();
- return;
- }
-
let manifest_path_arg = std::env::args().skip(2).find(|val| val.starts_with("--manifest-path="));
let mut metadata = cargo::metadata(manifest_path_arg.as_ref().map(AsRef::as_ref)).expect("could not obtain cargo metadata");