about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-07-27 14:39:08 +0000
committerbors <bors@rust-lang.org>2021-07-27 14:39:08 +0000
commitac0fd99194141f189b3fc41ef2d8925e6fa359c2 (patch)
tree1bb3afd686594d6be9d9200d0f4d0f3025c8d46e
parent43905d9f8d0f27d7ad71008bec9ef3c0b0982782 (diff)
parentf7af8bf2c1c361d7889f0edf398753bea97b8caa (diff)
downloadrust-ac0fd99194141f189b3fc41ef2d8925e6fa359c2.tar.gz
rust-ac0fd99194141f189b3fc41ef2d8925e6fa359c2.zip
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`.
-rw-r--r--src/main.rs9
-rw-r--r--tests/dogfood.rs2
2 files changed, 9 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 6bd4123ddeb..7589f42a7b4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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
 
@@ -71,6 +73,7 @@ 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() {
@@ -78,6 +81,10 @@ impl ClippyCmd {
                     cargo_subcommand = "fix";
                     continue;
                 },
+                "--no-deps" => {
+                    clippy_args.push("--no-deps".into());
+                    continue;
+                },
                 "--" => break,
                 _ => {},
             }
@@ -85,7 +92,7 @@ impl ClippyCmd {
             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());
         }
diff --git a/tests/dogfood.rs b/tests/dogfood.rs
index 7de130c7dbe..a996f9df144 100644
--- a/tests/dogfood.rs
+++ b/tests/dogfood.rs
@@ -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()