浏览代码

feat(bundle) add version to cargo-tauri-bundle subcommand (#31)

Lucas Fernandes Nogueira 6 年之前
父节点
当前提交
af41c71967
共有 1 个文件被更改,包括 20 次插入9 次删除
  1. 20 9
      tools/rust/cargo-tauri-bundle/src/main.rs

+ 20 - 9
tools/rust/cargo-tauri-bundle/src/main.rs

@@ -120,20 +120,31 @@ fn run() -> crate::Result<()> {
             .value_name("FEATURES")
             .multiple(true)
             .help("Which features to build"),
+        )
+        .arg(
+          Arg::with_name("version")
+            .long("version")
+            .short("v")
+            .help("Read the version of the CLI"),
         ),
     )
     .get_matches();
 
   if let Some(m) = m.subcommand_matches("tauri-bundle") {
-    let output_paths = env::current_dir()
-      .map_err(From::from)
-      .and_then(|d| Settings::new(d, m))
-      .and_then(|s| {
-        r#try!(build_project_if_unbuilt(&s));
-        Ok(s)
-      })
-      .and_then(bundle_project)?;
-    bundle::print_finished(&output_paths)?;
+    if m.is_present("version") {
+      println!("{}", crate_version!());
+    }
+    else {
+      let output_paths = env::current_dir()
+        .map_err(From::from)
+        .and_then(|d| Settings::new(d, m))
+        .and_then(|s| {
+          r#try!(build_project_if_unbuilt(&s));
+          Ok(s)
+        })
+        .and_then(bundle_project)?;
+      bundle::print_finished(&output_paths)?;
+    }
   }
   Ok(())
 }