From 5870d5b17c93b05f8e4c24e44a24e97adfdc7900 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 8 Mar 2018 12:05:42 +0300 Subject: [PATCH] Move read-manifest to clap --- src/bin/cargo.rs | 4 ++-- src/bin/cli/mod.rs | 10 +++++++++- src/bin/cli/read_manifest.rs | 8 ++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 src/bin/cli/read_manifest.rs diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 9a9b010b8..448ea8f6f 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" | "pkgid" | "publish" => true, + "owner" | "package" | "pkgid" | "publish" | "read-manifest" => true, _ => false }); @@ -138,7 +138,7 @@ macro_rules! each_subcommand{ // $mac!(package); // $mac!(pkgid); // $mac!(publish); - $mac!(read_manifest); +// $mac!(read_manifest); $mac!(run); $mac!(rustc); $mac!(rustdoc); diff --git a/src/bin/cli/mod.rs b/src/bin/cli/mod.rs index 86459623b..eb3b1df11 100644 --- a/src/bin/cli/mod.rs +++ b/src/bin/cli/mod.rs @@ -9,7 +9,7 @@ use std::path::PathBuf; use clap::{AppSettings, Arg, ArgMatches}; use cargo::{self, Config, CargoResult, CargoError, CliError}; -use cargo::core::{Workspace, Source, SourceId, GitReference}; +use cargo::core::{Workspace, Source, SourceId, GitReference, Package}; use cargo::util::{ToUrl, CargoResultExt}; use cargo::util::important_paths::find_root_manifest_for_wd; use cargo::ops::{self, MessageFormat, Packages, CompileOptions, CompileMode, VersionControl, @@ -448,6 +448,12 @@ about this warning."; })?; return Ok(()); } + ("read-manifest", Some(args)) => { + let root = root_manifest_from_args(config, args)?; + let pkg = Package::for_path(&root, config)?; + cargo::print_json(&pkg); + return Ok(()); + } _ => return Ok(()) } } @@ -535,6 +541,7 @@ See 'cargo help ' for more information on a specific command. package::cli(), pkgid::cli(), publish::cli(), + read_manifest::cli(), ]) ; app @@ -561,6 +568,7 @@ mod owner; mod package; mod pkgid; mod publish; +mod read_manifest; mod utils { use clap::{self, SubCommand, AppSettings}; diff --git a/src/bin/cli/read_manifest.rs b/src/bin/cli/read_manifest.rs new file mode 100644 index 000000000..29d3aa5de --- /dev/null +++ b/src/bin/cli/read_manifest.rs @@ -0,0 +1,8 @@ +use super::utils::*; + +pub fn cli() -> App { + subcommand("read-manifest") + .about("Deprecated, use `cargo metadata --no-deps` instead. +Print a JSON representation of a Cargo.toml manifest.") + .arg_manifest_path() +} -- 2.30.2