From: Aleksey Kladov Date: Wed, 7 Mar 2018 15:02:36 +0000 (+0300) Subject: Move pkgid to clap X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~2^2~47^2~51 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5c8135304de76f8f32ca76f2f4a0139d481e2c0c;p=cargo.git Move pkgid to clap --- diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index bb7e9319e..5efdd34a2 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -91,7 +91,7 @@ fn main() { 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 }); @@ -136,7 +136,7 @@ macro_rules! each_subcommand{ // $mac!(new); // $mac!(owner); // $mac!(package); - $mac!(pkgid); +// $mac!(pkgid); $mac!(publish); $mac!(read_manifest); $mac!(run); diff --git a/src/bin/cli/mod.rs b/src/bin/cli/mod.rs index e2dbbb1fd..89114bca7 100644 --- a/src/bin/cli/mod.rs +++ b/src/bin/cli/mod.rs @@ -400,6 +400,13 @@ pub fn do_main(config: &mut Config) -> Result<(), CliError> { })?; 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(()) } } @@ -485,6 +492,7 @@ See 'cargo help ' for more information on a specific command. new::cli(), owner::cli(), package::cli(), + pkgid::cli(), ]) ; app @@ -509,6 +517,7 @@ mod metadata; mod new; mod owner; mod package; +mod pkgid; mod utils { use clap::{self, SubCommand, AppSettings}; diff --git a/src/bin/cli/pkgid.rs b/src/bin/cli/pkgid.rs new file mode 100644 index 000000000..5c4cd8442 --- /dev/null +++ b/src/bin/cli/pkgid.rs @@ -0,0 +1,32 @@ +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 argument, print out the fully qualified package id specifier. +This command will generate an error if is ambiguous as to which package +it refers to in the dependency graph. If no 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 +") +}