diff --git a/coffee_cmd/src/coffee_term/command_show.rs b/coffee_cmd/src/coffee_term/command_show.rs index 819635c..6706ef8 100644 --- a/coffee_cmd/src/coffee_term/command_show.rs +++ b/coffee_cmd/src/coffee_term/command_show.rs @@ -14,22 +14,31 @@ pub fn show_list(coffee_list: Result) -> Result<(), Cof term::println( term::format::bold("●"), - term::format::tertiary("Plugin installed"), + term::format::tertiary("Plugins installed"), ); let mut table = radicle_term::Table::new(TableOptions::bordered()); table.push([ term::format::dim(String::from("●")), term::format::bold(String::from("Language")), term::format::bold(String::from("Name")), + term::format::bold(String::from("Enabled?")), term::format::bold(String::from("Exec path")), ]); table.divider(); for plugin in &remotes.plugins { + // Get whether the plugin is enabled + // If enabled is None, it means the plugin is enabled by default for backward compatibility. + let enabled = plugin.enabled.unwrap_or(true); table.push([ term::format::positive("●").into(), term::format::highlight(plugin.lang.to_string()), term::format::bold(plugin.name()), + if enabled { + term::format::positive("yes").into() + } else { + term::format::negative("no").into() + }, term::format::highlight(plugin.exec_path.to_owned()), ]) } diff --git a/coffee_core/src/coffee.rs b/coffee_core/src/coffee.rs index 98e32c9..47fbb98 100644 --- a/coffee_core/src/coffee.rs +++ b/coffee_core/src/coffee.rs @@ -289,6 +289,8 @@ impl PluginManager for CoffeeManager { let path = plugin.configure(verbose).await?; log::debug!("runnable plugin path {path}"); if !try_dynamic { + // mark the plugin enabled + plugin.enabled = Some(true); self.config.plugins.push(plugin); log::debug!("path coffee conf: {}", self.coffee_cln_config.path); self.coffee_cln_config diff --git a/coffee_github/src/repository.rs b/coffee_github/src/repository.rs index 589f135..be237e6 100644 --- a/coffee_github/src/repository.rs +++ b/coffee_github/src/repository.rs @@ -186,6 +186,9 @@ impl Github { plugin_lang, conf.clone(), commit_id.clone(), + // The plugin for now is not installed, so it's + // neither enabled or disabled + None, ); debug!("new plugin: {:?}", plugin); diff --git a/coffee_lib/src/plugin.rs b/coffee_lib/src/plugin.rs index e32b052..fda5ba2 100644 --- a/coffee_lib/src/plugin.rs +++ b/coffee_lib/src/plugin.rs @@ -104,6 +104,8 @@ pub struct Plugin { conf: Option, /// FIXME: this field shouldn't be optional pub commit: Option, + /// Optional for now to be backward compatible + pub enabled: Option, } impl Plugin { @@ -115,6 +117,7 @@ impl Plugin { plugin_lang: PluginLang, config: Option, commit_id: Option, + enabled: Option, ) -> Self { Plugin { name: name.to_owned(), @@ -123,6 +126,7 @@ impl Plugin { lang: plugin_lang, conf: config, commit: commit_id, + enabled, } }