forked from DioxusLabs/dioxus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
062d0ea
commit 6cce4b9
Showing
5 changed files
with
82 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use crate::tools; | ||
|
||
use super::*; | ||
|
||
/// Build the Rust WASM app and all of its assets. | ||
#[derive(Clone, Debug, Deserialize, Subcommand)] | ||
#[clap(name = "plugin")] | ||
pub enum Plugin { | ||
/// Return all dioxus-cli support tools. | ||
List {}, | ||
/// Get default app install path. | ||
AppPath {}, | ||
/// Install a new tool. | ||
Add { name: String }, | ||
} | ||
|
||
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}"); | ||
} | ||
} | ||
} | ||
Plugin::AppPath {} => { | ||
if let Some(v) = tools::tools_path().to_str() { | ||
println!("{}", v); | ||
} else { | ||
log::error!("Tools 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!"); | ||
} | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters