Auto merge of #7492 - nfejzic:improve_help, r=Manishearth

Explain flags missing in cargo check in --help

This commit closes #7389. As stated in the issue, `cargo clippy --help`
provides explanation for some flags and states that the rest are same
as in `cargo check --help`, even though some clippy specific flags
exist.

This commit extends the `cargo clippy --help` with two additional flags,
  - `cargo clippy --fix`
  - `cargo clippy --no-deps`

If there are more flags which are not present in `cargo check --help`
please bring these to my attention, I will include these aswell.
For now, I noticed only the two flags mentioned above.

changelog: `cargo clippy --help` now explains additional flags missing in `cargo check --help`.
This commit is contained in:
bors 2021-07-27 14:39:08 +00:00
commit ac0fd99194
2 changed files with 9 additions and 2 deletions

View File

@ -14,6 +14,8 @@
cargo clippy [options] [--] [<opts>...]
Common options:
--no-deps Run Clippy only on the given crate, without linting the dependencies
--fix Automatically apply lint suggestions. This flag implies `--no-deps`
-h, --help Print this message
-V, --version Print version info and exit
@ -71,6 +73,7 @@ fn new<I>(mut old_args: I) -> Self
{
let mut cargo_subcommand = "check";
let mut args = vec![];
let mut clippy_args: Vec<String> = vec![];
for arg in old_args.by_ref() {
match arg.as_str() {
@ -78,6 +81,10 @@ fn new<I>(mut old_args: I) -> Self
cargo_subcommand = "fix";
continue;
},
"--no-deps" => {
clippy_args.push("--no-deps".into());
continue;
},
"--" => break,
_ => {},
}
@ -85,7 +92,7 @@ fn new<I>(mut old_args: I) -> Self
args.push(arg);
}
let mut clippy_args: Vec<String> = old_args.collect();
clippy_args.append(&mut (old_args.collect()));
if cargo_subcommand == "fix" && !clippy_args.iter().any(|arg| arg == "--no-deps") {
clippy_args.push("--no-deps".into());
}

View File

@ -76,8 +76,8 @@ fn test_no_deps_ignores_path_deps_in_workspaces() {
.env("CARGO_INCREMENTAL", "0")
.arg("clippy")
.args(&["-p", "subcrate"])
.arg("--")
.arg("--no-deps")
.arg("--")
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
.args(&["--cfg", r#"feature="primary_package_test""#])
.output()