origen/commands/
plugins.rs

1use super::_prelude::*;
2
3pub const BASE_CMD: &'static str = "plugins";
4
5gen_core_cmd_funcs__no_exts__no_app_opts!(
6    BASE_CMD,
7    "Interface with the Origen plugin manager",
8    {
9        |cmd: App| {
10            cmd.visible_alias("pl_mgr")
11                .visible_alias("pls")
12                .arg_required_else_help(true)
13        }
14    },
15    core_subcmd__no_exts__no_app_opts!("list", "List the available plugins", {
16        |cmd: App| cmd.visible_alias("ls")
17    })
18);
19
20pub fn run(cmd: RunInput, plugins: Option<&Plugins>) -> Result<()> {
21    if let Some(subcmd) = cmd.subcommand() {
22        match subcmd.0 {
23            "list" => {
24                if let Some(pls) = plugins {
25                    if pls.is_empty() {
26                        displayln!("There are no available plugins!");
27                    } else {
28                        displayln!("Available plugins:\n");
29                        for (name, _) in pls.plugins.iter() {
30                            displayln!("{}", name);
31                        }
32                    }
33                } else {
34                    displayln!("The plugin manager is not available or there was an error populating plugins!");
35                }
36            }
37            _ => unreachable_invalid_subc!(subcmd.0),
38        }
39    }
40    Ok(())
41}