]> git.proxmox.com Git - cargo.git/commitdiff
pkgid: add the -p flag as the output suggests
authorDoug Goldstein <cardoe@cardoe.com>
Tue, 18 Oct 2016 05:24:53 +0000 (00:24 -0500)
committerDoug Goldstein <cardoe@cardoe.com>
Tue, 18 Oct 2016 06:17:10 +0000 (01:17 -0500)
When you use this command and there are multiple packages that match
this spec, the help instructions tell you to rerun it with the -p
argument which was previously not present. Since the code paths are
shared with 'cargo build' and 'cargo update', this adds the -p argument
to 'cargo pkgid' to make things more consistent.

Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
src/bin/pkgid.rs

index 13aedf257a77537d60b91e516fa25e4af9a427c5..f9d90523ceae29cb2e7689767ca90ff3d76bcd97 100644 (file)
@@ -11,6 +11,7 @@ pub struct Options {
     flag_manifest_path: Option<String>,
     flag_frozen: bool,
     flag_locked: bool,
+    flag_package: Option<String>,
     arg_spec: Option<String>,
 }
 
@@ -22,6 +23,7 @@ Usage:
 
 Options:
     -h, --help               Print this message
+    -p SPEC, --package SPEC  Argument to get the package id specifier for
     --manifest-path PATH     Path to the manifest to the package to clean
     -v, --verbose ...        Use verbose output
     -q, --quiet              No output printed to stdout
@@ -60,7 +62,14 @@ pub fn execute(options: Options,
     let root = try!(find_root_manifest_for_wd(options.flag_manifest_path.clone(), config.cwd()));
     let ws = try!(Workspace::new(&root, config));
 
-    let spec = options.arg_spec.as_ref().map(|s| &s[..]);
+    let spec = if options.arg_spec.is_some() {
+        options.arg_spec
+    } else if options.flag_package.is_some() {
+        options.flag_package
+    } else {
+        None
+    };
+    let spec = spec.as_ref().map(|s| &s[..]);
     let spec = try!(ops::pkgid(&ws, spec));
     println!("{}", spec);
     Ok(None)