let is_clapified = ::std::env::args().any(|arg| match arg.as_ref() {
"build" | "bench" | "check" | "clean" | "doc" | "fetch" | "generate-lockfile" | "git-checkout" |
"init" | "install" | "locate-project" | "login" | "metadata" | "new" |
- "owner" | "package" => true,
+ "owner" | "package" | "pkgid"=> true,
_ => false
});
// $mac!(new);
// $mac!(owner);
// $mac!(package);
- $mac!(pkgid);
+// $mac!(pkgid);
$mac!(publish);
$mac!(read_manifest);
$mac!(run);
})?;
return Ok(());
}
+ ("pkgid", Some(args)) => {
+ let ws = workspace_from_args(config, args)?;
+ let spec = args.value_of("spec").or(args.value_of("package"));
+ let spec = ops::pkgid(&ws, spec)?;
+ println!("{}", spec);
+ Ok(())
+ }
_ => return Ok(())
}
}
new::cli(),
owner::cli(),
package::cli(),
+ pkgid::cli(),
])
;
app
mod new;
mod owner;
mod package;
+mod pkgid;
mod utils {
use clap::{self, SubCommand, AppSettings};
--- /dev/null
+use super::utils::*;
+
+pub fn cli() -> App {
+ subcommand("pkgid")
+ .about("Print a fully qualified package specification")
+ .arg(Arg::with_name("spec"))
+ .arg(
+ opt("package", "Argument to get the package id specifier for")
+ .short("p").value_name("SPEC")
+ )
+ .arg_manifest_path()
+ .after_help("\
+Given a <spec> argument, print out the fully qualified package id specifier.
+This command will generate an error if <spec> is ambiguous as to which package
+it refers to in the dependency graph. If no <spec> is given, then the pkgid for
+the local package is printed.
+
+This command requires that a lockfile is available and dependencies have been
+fetched.
+
+Example Package IDs
+
+ pkgid | name | version | url
+ |-----------------------------|--------|-----------|---------------------|
+ foo | foo | * | *
+ foo:1.2.3 | foo | 1.2.3 | *
+ crates.io/foo | foo | * | *://crates.io/foo
+ crates.io/foo#1.2.3 | foo | 1.2.3 | *://crates.io/foo
+ crates.io/bar#foo:1.2.3 | foo | 1.2.3 | *://crates.io/bar
+ http://crates.io/foo#1.2.3 | foo | 1.2.3 | http://crates.io/foo
+")
+}