瀏覽代碼

Made clone_repo error clear.

Ell 2 年之前
父節點
當前提交
60eb453aad
共有 2 個文件被更改,包括 9 次插入5 次删除
  1. 1 3
      src/cli/translate/mod.rs
  2. 8 2
      src/tools.rs

+ 1 - 3
src/cli/translate/mod.rs

@@ -1,8 +1,6 @@
 use std::process::exit;
 
-use dioxus_rsx::{BodyNode, CallBody, Component};
-use proc_macro2::{Ident, Span};
-use syn::punctuated::Punctuated;
+use dioxus_rsx::{BodyNode, CallBody};
 
 use super::*;
 

+ 8 - 2
src/tools.rs

@@ -1,6 +1,6 @@
 use std::{
     fs::{create_dir_all, File},
-    io::{Read, Write},
+    io::{Read, Write, ErrorKind},
     path::{Path, PathBuf},
     process::Command,
 };
@@ -46,7 +46,13 @@ pub fn clone_repo(dir: &Path, url: &str) -> anyhow::Result<()> {
 
     let mut cmd = Command::new("git");
     let cmd = cmd.current_dir(target_dir);
-    let _res = cmd.arg("clone").arg(url).arg(dir_name).output()?;
+    let res = cmd.arg("clone").arg(url).arg(dir_name).output();
+    if let Err(err) = res {
+        if ErrorKind::NotFound == err.kind() {
+            log::error!("Git program not found. Hint: Install git or check $PATH.");
+            return Err(err.into());
+        }
+    }
     Ok(())
 }