Repository: dtolnay/cargo-expand (language: rust)

Issue:
Implement the `-p` argument
Currently `cargo expand -p some-workspace-crate` fails with the following 

```
Found argument '-p' which wasn't expected, or isn't valid in this context
```

It would be nice to expand macros in other workspace crates.


Discussion / hints:

Fix patch:
diff --git a/src/main.rs b/src/main.rs
index 231178c..32394c4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -306,6 +306,11 @@ fn apply_args(cmd: &mut Command, args: &Args, outfile: &Path) {
         line.arg(manifest_path);
     }
 
+    if let Some(package) = &args.package {
+        line.arg("--package");
+        line.arg(package);
+    }
+
     if let Some(jobs) = args.jobs {
         line.arg("--jobs");
         line.arg(jobs.to_string());
diff --git a/src/opts.rs b/src/opts.rs
index 8d674c9..1a02ea8 100644
--- a/src/opts.rs
+++ b/src/opts.rs
@@ -73,6 +73,10 @@ pub struct Args {
     #[structopt(long, value_name = "PATH", parse(from_os_str))]
     pub manifest_path: Option<PathBuf>,
 
+    /// Package to expand
+    #[structopt(short, long, value_name = "SPEC")]
+    pub package: Option<String>,
+
     /// Number of parallel jobs, defaults to # of CPUs
     #[structopt(short, long, value_name = "N")]
     pub jobs: Option<u64>,


Test patch: