Skip to content

Commit

Permalink
Auto merge of #7492 - nfejzic:improve_help, r=Manishearth
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
bors committed Jul 27, 2021
2 parents 43905d9 + f7af8bf commit ac0fd99
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Usage:
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
Expand Down Expand Up @@ -71,21 +73,26 @@ impl ClippyCmd {
{
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() {
"--fix" => {
cargo_subcommand = "fix";
continue;
},
"--no-deps" => {
clippy_args.push("--no-deps".into());
continue;
},
"--" => break,
_ => {},
}

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());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/dogfood.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ac0fd99

Please sign in to comment.