diff --git a/src/cli/plugin/mod.rs b/src/cli/plugin/mod.rs index 9179f5bd6..ca2937306 100644 --- a/src/cli/plugin/mod.rs +++ b/src/cli/plugin/mod.rs @@ -21,10 +21,12 @@ impl Plugin { } } Plugin::AppPath {} => { - if let Some(v) = crate::plugin::PluginManager::init_plugin_dir().to_str() { - println!("{}", v); - } else { - log::error!("Plugin path get failed."); + if let Ok(plugin_dir) = crate::plugin::PluginManager::init_plugin_dir() { + if let Some(v) = plugin_dir.to_str() { + println!("{}", v); + } else { + log::error!("Plugin path get failed."); + } } } Plugin::Add { name: _ } => { diff --git a/src/plugin/mod.rs b/src/plugin/mod.rs index c75e96444..5648b395f 100644 --- a/src/plugin/mod.rs +++ b/src/plugin/mod.rs @@ -42,7 +42,7 @@ impl PluginManager { let manager = lua.create_table().unwrap(); let name_index = lua.create_table().unwrap(); - let plugin_dir = Self::init_plugin_dir(); + let plugin_dir = Self::init_plugin_dir().unwrap(); let api = lua.create_table().unwrap(); @@ -288,15 +288,17 @@ impl PluginManager { Ok(()) } - pub fn init_plugin_dir() -> PathBuf { + pub fn init_plugin_dir() -> anyhow::Result { let app_path = app_path(); let plugin_path = app_path.join("plugins"); if !plugin_path.is_dir() { log::info!("📖 Start to init plugin library ..."); let url = "https://github.com/DioxusLabs/cli-plugin-library"; - clone_repo(&plugin_path, url).unwrap(); + if let Err(err) = clone_repo(&plugin_path, url) { + log::error!("Failed to init plugin dir, error caused by {}. ", err); + } } - plugin_path + Ok(plugin_path) } pub fn plugin_list() -> Vec { diff --git a/src/tools.rs b/src/tools.rs index 37ecc4e38..f11befaf5 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -49,7 +49,7 @@ pub fn clone_repo(dir: &Path, url: &str) -> anyhow::Result<()> { 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."); + log::warn!("Git program not found. Hint: Install git or check $PATH."); return Err(err.into()); } }