Skip to content

Commit 1ad3b6b

Browse files
committed
feat: branch support in installation
1 parent a9a0523 commit 1ad3b6b

File tree

8 files changed

+20
-7
lines changed

8 files changed

+20
-7
lines changed

coffee_cmd/src/cmd.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ pub enum CoffeeCommand {
2929
verbose: bool,
3030
#[arg(short, long, action = clap::ArgAction::SetTrue)]
3131
dynamic: bool,
32+
#[arg(short, long, action = clap::ArgAction::SetTrue)]
33+
branch: Option<String>,
3234
},
3335
/// upgrade a single repository.
3436
#[clap(arg_required_else_help = true)]
@@ -89,7 +91,8 @@ impl From<&CoffeeCommand> for coffee_core::CoffeeOperation {
8991
plugin,
9092
verbose,
9193
dynamic,
92-
} => Self::Install(plugin.to_owned(), *verbose, *dynamic),
94+
branch,
95+
} => Self::Install(plugin.to_owned(), *verbose, *dynamic, branch.to_owned()),
9396
CoffeeCommand::Upgrade { repo, verbose } => Self::Upgrade(repo.to_owned(), *verbose),
9497
CoffeeCommand::List {} => Self::List,
9598
CoffeeCommand::Setup { cln_conf } => Self::Setup(cln_conf.to_owned()),

coffee_cmd/src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ async fn main() -> Result<(), CoffeeError> {
2424
plugin,
2525
verbose,
2626
dynamic,
27+
branch,
2728
} => {
2829
let spinner = if !verbose {
2930
Some(term::spinner("Compiling and installing"))
3031
} else {
3132
None
3233
};
33-
let result = coffee.install(&plugin, verbose, dynamic).await;
34+
let result = coffee.install(&plugin, verbose, dynamic, branch).await;
3435
if let Some(spinner) = spinner {
3536
if result.is_ok() {
3637
spinner.finish();

coffee_core/src/coffee.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ impl PluginManager for CoffeeManager {
247247
plugin: &str,
248248
verbose: bool,
249249
try_dynamic: bool,
250+
_branch: Option<String>,
250251
) -> Result<(), CoffeeError> {
251252
log::debug!("installing plugin: {plugin}");
252253
// keep track if the plugin is successfully installed
@@ -355,7 +356,7 @@ impl PluginManager for CoffeeManager {
355356
let status = repository.upgrade(&self.config.plugins).await?;
356357
for plugins in status.plugins_effected.iter() {
357358
self.remove(plugins).await?;
358-
self.install(plugins, verbose, false).await?;
359+
self.install(plugins, verbose, false, None).await?;
359360
}
360361
self.flush().await?;
361362
Ok(status)

coffee_core/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ pub use coffee_lib as lib;
77

88
#[derive(Clone, Debug)]
99
pub enum CoffeeOperation {
10-
/// Install(plugin name, verbose run, dynamic installation)
11-
Install(String, bool, bool),
10+
/// Install(plugin name, verbose run, dynamic installation, branch)
11+
Install(String, bool, bool, Option<String>),
1212
/// List
1313
List,
1414
// Upgrade(name of the repository, verbose run)

coffee_httpd/src/httpd/server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async fn coffee_install(
9191
let try_dynamic = body.try_dynamic;
9292

9393
let mut coffee = data.coffee.lock().await;
94-
let result = coffee.install(plugin, false, try_dynamic).await;
94+
let result = coffee.install(plugin, false, try_dynamic, None).await;
9595

9696
handle_httpd_response!(result, "Plugin '{plugin}' installed successfully")
9797
}

coffee_lib/src/plugin_manager.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub trait PluginManager {
1616
plugins: &str,
1717
verbose: bool,
1818
try_dynamic: bool,
19+
branch: Option<String>,
1920
) -> Result<(), CoffeeError>;
2021

2122
// remove a plugin by name, return an error if some error happens.

coffee_plugin/src/plugin/plugin_mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl RPCCommand<State> for CoffeeInstall {
9898
let rt = Runtime::new().unwrap();
9999

100100
let request: InstallReq = serde_json::from_value(request)?;
101-
rt.block_on(coffee.install(&request.name, false, true))
101+
rt.block_on(coffee.install(&request.name, false, true, None))
102102
.map_err(from)?;
103103
Ok(json!({}))
104104
}

docs/docs-book/src/using-coffee.md

+7
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ To install a plugin statically, you simply need to run.
104104
coffee install <plugin_name>
105105
```
106106

107+
#### Branch Specification for Plugin Installation
108+
109+
User can install a plugin from a specific branch using the command:
110+
```bash
111+
coffee install <plugin_name> --branch <branch_name>
112+
```
113+
107114
### Removing a Plugin
108115

109116
> ✅ Implemented

0 commit comments

Comments
 (0)