1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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 crate::plugin::PluginManager::plugin_list() {
                    println!("- {item}");
                }
            }
            Plugin::AppPath {} => {
                if let Some(v) = crate::plugin::PluginManager::init_plugin_dir().to_str() {
                    println!("{}", v);
                } else {
                    log::error!("Plugin path get failed.");
                }
            }
            Plugin::Add { name: _ } => {
                log::info!("You can use `dioxus plugin app-path` to get Installation position");
            }
        }
        Ok(())
    }
}