From 287d3526008776f7b3bbbc6c7b62130a9d85bba3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 7 Mar 2018 11:35:17 +0300 Subject: [PATCH] Move generate-lockfile to clap --- src/bin/cargo.rs | 4 ++-- src/bin/cli/fetch.rs | 3 --- src/bin/cli/generate_lockfile.rs | 18 ++++++++++++++++++ src/bin/cli/mod.rs | 8 ++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 src/bin/cli/generate_lockfile.rs diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index f938572f2..ab9b31324 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -89,7 +89,7 @@ fn main() { }; let is_clapified = ::std::env::args().any(|arg| match arg.as_ref() { - "build" | "bench" | "check" | "clean" | "doc" | "fetch" => true, + "build" | "bench" | "check" | "clean" | "doc" | "fetch" | "generate-lockfile" => true, _ => false }); @@ -123,7 +123,7 @@ macro_rules! each_subcommand{ // $mac!(clean); // $mac!(doc); // $mac!(fetch); - $mac!(generate_lockfile); +// $mac!(generate_lockfile); $mac!(git_checkout); $mac!(help); $mac!(init); diff --git a/src/bin/cli/fetch.rs b/src/bin/cli/fetch.rs index 068237ec6..1a7a0b551 100644 --- a/src/bin/cli/fetch.rs +++ b/src/bin/cli/fetch.rs @@ -3,9 +3,6 @@ use super::utils::*; pub fn cli() -> App { subcommand("fetch") .about("Fetch dependencies of a package from the network") - .arg( - opt("open", "Opens the docs in a browser after the operation") - ) .arg_manifest_path() .arg_locked() .after_help("\ diff --git a/src/bin/cli/generate_lockfile.rs b/src/bin/cli/generate_lockfile.rs new file mode 100644 index 000000000..faf0c35e7 --- /dev/null +++ b/src/bin/cli/generate_lockfile.rs @@ -0,0 +1,18 @@ +use super::utils::*; + +pub fn cli() -> App { + subcommand("generate-lockfile") + .about("Generate the lockfile for a project") + .arg_manifest_path() + .arg_locked() + .after_help("\ +If a lockfile is available, this command will ensure that all of the git +dependencies and/or registries dependencies are downloaded and locally +available. The network is never touched after a `cargo fetch` unless +the lockfile changes. + +If the lockfile is not available, then this is the equivalent of +`cargo generate-lockfile`. A lockfile is generated and dependencies are also +all updated. +") +} diff --git a/src/bin/cli/mod.rs b/src/bin/cli/mod.rs index f1465ab13..9fdc5d897 100644 --- a/src/bin/cli/mod.rs +++ b/src/bin/cli/mod.rs @@ -188,6 +188,12 @@ pub fn do_main(config: &mut Config) -> Result<(), CliError> { ops::fetch(&ws)?; return Ok(()); } + ("generate-lockfile", Some(args)) => { + config_from_args(config, args)?; + let ws = workspace_from_args(config, args)?; + ops::generate_lockfile(&ws)?; + return Ok(()); + } _ => return Ok(()) } } @@ -256,6 +262,7 @@ See 'cargo help ' for more information on a specific command. clean::cli(), doc::cli(), fetch::cli(), + generate_lockfile::cli(), ]) ; app @@ -267,6 +274,7 @@ mod check; mod clean; mod doc; mod fetch; +mod generate_lockfile; mod utils { use clap::{self, SubCommand, AppSettings}; -- 2.30.2