feat: add some command
This commit is contained in:
1 parent
9ee572ad26
commit
6004cfdd40
4 files changed
+35
-56
No files matched your search
+6
-35
@@ -18,48 +18,19 @@ impl Plugin {
|
||||
pub async fn plugin(self) -> Result<()> {
|
||||
match self {
|
||||
Plugin::List {} => {
|
||||
for item in tools::tool_list() {
|
||||
if tools::Tool::from_str(item).unwrap().is_installed() {
|
||||
println!("- {item} [installed]");
|
||||
} else {
|
||||
println!("- {item}");
|
||||
}
|
||||
for item in crate::plugin::PluginManager::plugin_list() {
|
||||
println!("- {item}");
|
||||
}
|
||||
}
|
||||
Plugin::AppPath {} => {
|
||||
if let Some(v) = tools::tools_path().to_str() {
|
||||
if let Some(v) = crate::plugin::PluginManager::init_plugin_dir().to_str() {
|
||||
println!("{}", v);
|
||||
} else {
|
||||
log::error!("Tools path get failed.");
|
||||
log::error!("Plugin path get failed.");
|
||||
}
|
||||
}
|
||||
Plugin::Add { name } => {
|
||||
let tool_list = tools::tool_list();
|
||||
|
||||
if !tool_list.contains(&name.as_str()) {
|
||||
log::error!("Tool {name} not found.");
|
||||
return Ok(());
|
||||
}
|
||||
let target_tool = tools::Tool::from_str(&name).unwrap();
|
||||
|
||||
if target_tool.is_installed() {
|
||||
log::warn!("Tool {name} is installed.");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
log::info!("Start to download tool package...");
|
||||
if let Err(e) = target_tool.download_package().await {
|
||||
log::error!("Tool download failed: {e}");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
log::info!("Start to install tool package...");
|
||||
if let Err(e) = target_tool.install_package().await {
|
||||
log::error!("Tool install failed: {e}");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
log::info!("Tool {name} install successfully!");
|
||||
Plugin::Add { name: _ } => {
|
||||
log::info!("You can use `dioxus plugin app-path` to get Installation position");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
||||
Reference in new issue
Block a user