Move generate-lockfile to clap
authorAleksey Kladov <aleksey.kladov@gmail.com>
Wed, 7 Mar 2018 08:35:17 +0000 (11:35 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Thu, 8 Mar 2018 20:30:46 +0000 (23:30 +0300)
src/bin/cargo.rs
src/bin/cli/fetch.rs
src/bin/cli/generate_lockfile.rs [new file with mode: 0644]
src/bin/cli/mod.rs

index f938572f2989df7174a1d2461bbe9b1ccf4e3504..ab9b31324cf51f1806b42ab220576b9c412fa888 100644 (file)
@@ -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);
index 068237ec673605e91bfd99a424c427e54281b31e..1a7a0b551fe71475b64228648467f53ada88364f 100644 (file)
@@ -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 (file)
index 0000000..faf0c35
--- /dev/null
@@ -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.
+")
+}
index f1465ab13fefb3505fb175f8a2ede3a10f1e3d54..9fdc5d89719506ce7d1dd0abda9f3a4896dbc4a1 100644 (file)
@@ -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 <command>' 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};