Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add coffee disable and coffee enable Commands #240

Merged
merged 4 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion coffee_cmd/src/coffee_term/command_show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,31 @@ pub fn show_list(coffee_list: Result<CoffeeList, CoffeeError>) -> 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?")),
tareknaser marked this conversation as resolved.
Show resolved Hide resolved
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()),
])
}
Expand Down
2 changes: 2 additions & 0 deletions coffee_core/src/coffee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions coffee_github/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions coffee_lib/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ pub struct Plugin {
conf: Option<Conf>,
/// FIXME: this field shouldn't be optional
pub commit: Option<String>,
/// Optional for now to be backward compatible
tareknaser marked this conversation as resolved.
Show resolved Hide resolved
pub enabled: Option<bool>,
}

impl Plugin {
Expand All @@ -115,6 +117,7 @@ impl Plugin {
plugin_lang: PluginLang,
config: Option<Conf>,
commit_id: Option<String>,
enabled: Option<bool>,
) -> Self {
Plugin {
name: name.to_owned(),
Expand All @@ -123,6 +126,7 @@ impl Plugin {
lang: plugin_lang,
conf: config,
commit: commit_id,
enabled,
}
}

Expand Down