Skip to content

Commit 8a494e1

Browse files
committed
refactor: rename setup command to link
- Rename `coffee setup` command to `coffee link` - Change function names from `setup_*` to `link_*` (e.g., `setup_with_cln` to `link_with_cln`) - Update command references in `httpd` and `plugin` crates - Modify relevant documentation to reflect the command name change This refactor is to accommodate the addition of a new `unlink` command. Signed-off-by: Tarek <[email protected]>
1 parent ad160b2 commit 8a494e1

File tree

11 files changed

+32
-37
lines changed

11 files changed

+32
-37
lines changed

coffee_cmd/src/cmd.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ pub struct CoffeeArgs {
2626
/// Coffee subcommand of the command line daemon.
2727
#[derive(Debug, Subcommand)]
2828
pub enum CoffeeCommand {
29+
/// Configure coffee with the core lightning
30+
/// configuration
31+
#[clap(arg_required_else_help = true)]
32+
Link { cln_conf: String },
2933
/// Install a single by name.
3034
#[clap(arg_required_else_help = true)]
3135
Install {
@@ -56,10 +60,6 @@ pub enum CoffeeCommand {
5660
#[arg(name = "remote-name", help = "The name of the remote repository")]
5761
name: Option<String>,
5862
},
59-
/// Configure coffee with the core lightning
60-
/// configuration
61-
#[clap(arg_required_else_help = true)]
62-
Setup { cln_conf: String },
6363
/// show the README file of the plugin
6464
#[clap(arg_required_else_help = true)]
6565
Show { plugin: String },
@@ -99,14 +99,14 @@ pub enum RemoteAction {
9999
impl From<&CoffeeCommand> for coffee_core::CoffeeOperation {
100100
fn from(value: &CoffeeCommand) -> Self {
101101
match value {
102+
CoffeeCommand::Link { cln_conf } => Self::Link(cln_conf.to_owned()),
102103
CoffeeCommand::Install {
103104
plugin,
104105
verbose,
105106
dynamic,
106107
} => Self::Install(plugin.to_owned(), *verbose, *dynamic),
107108
CoffeeCommand::Upgrade { repo, verbose } => Self::Upgrade(repo.to_owned(), *verbose),
108109
CoffeeCommand::List {} => Self::List,
109-
CoffeeCommand::Setup { cln_conf } => Self::Setup(cln_conf.to_owned()),
110110
CoffeeCommand::Remote { action, name } => {
111111
if let Some(action) = action {
112112
return Self::Remote(Some(action.into()), name.clone());

coffee_cmd/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ use crate::cmd::RemoteAction;
1616

1717
async fn run(args: CoffeeArgs, mut coffee: CoffeeManager) -> Result<(), CoffeeError> {
1818
match args.command {
19+
CoffeeCommand::Link { cln_conf } => {
20+
// FIXME: read the core lightning config
21+
// and the coffee script
22+
coffee.link(&cln_conf).await?;
23+
}
1924
CoffeeCommand::Install {
2025
plugin,
2126
verbose,
@@ -134,11 +139,6 @@ async fn run(args: CoffeeArgs, mut coffee: CoffeeManager) -> Result<(), CoffeeEr
134139
}
135140
}
136141
}
137-
CoffeeCommand::Setup { cln_conf } => {
138-
// FIXME: read the core lightning config
139-
// and the coffee script
140-
coffee.setup(&cln_conf).await?;
141-
}
142142
CoffeeCommand::Show { plugin } => {
143143
let val = coffee.show(&plugin).await?;
144144

coffee_core/src/coffee.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl CoffeeManager {
228228
Ok(())
229229
}
230230

231-
pub async fn setup_with_cln(&mut self, cln_dir: &str) -> Result<(), CoffeeError> {
231+
pub async fn link_with_cln(&mut self, cln_dir: &str) -> Result<(), CoffeeError> {
232232
if self.cln_config.is_some() {
233233
log::warn!("you are overriding the previous set up");
234234
}
@@ -417,8 +417,8 @@ impl PluginManager for CoffeeManager {
417417
Ok(status)
418418
}
419419

420-
async fn setup(&mut self, cln_dir: &str) -> Result<(), CoffeeError> {
421-
self.setup_with_cln(cln_dir).await?;
420+
async fn link(&mut self, cln_dir: &str) -> Result<(), CoffeeError> {
421+
self.link_with_cln(cln_dir).await?;
422422
log::info!("cln configured");
423423
self.flush().await?;
424424
Ok(())

coffee_core/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ pub use coffee_lib as lib;
77

88
#[derive(Clone, Debug)]
99
pub enum CoffeeOperation {
10+
/// Link coffee to the lightning configuration file
11+
Link(String),
1012
/// Install(plugin name, verbose run, dynamic installation)
1113
Install(String, bool, bool),
1214
/// List
@@ -16,8 +18,6 @@ pub enum CoffeeOperation {
1618
Remove(String),
1719
/// Remote(name repository, url of the repository)
1820
Remote(Option<RemoteAction>, Option<String>),
19-
/// Setup(core lightning root path)
20-
Setup(String),
2121
Show(String),
2222
/// Search(plugin name)
2323
Search(String),

coffee_httpd/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ async fn main() -> Result<(), CoffeeError> {
1313
env_logger::init();
1414
let cmd = cmd::HttpdArgs::parse();
1515
let mut coffee = CoffeeManager::new(&cmd).await?;
16-
coffee.setup(&cmd.cln_path).await?;
16+
coffee.link(&cmd.cln_path).await?;
1717

1818
let port = cmd.port.unwrap_or(8080) as u16;
1919
log::info!("Running on port 127.0.0.1:{port}");

coffee_lib/src/plugin_manager.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ pub trait PluginManager {
3939
/// List the plugins available in a remote repository.
4040
async fn get_plugins_in_remote(&self, name: &str) -> Result<CoffeeList, CoffeeError>;
4141

42-
/// set up the core lightning configuration target for the
43-
/// plugin manager.
44-
async fn setup(&mut self, cln_conf_path: &str) -> Result<(), CoffeeError>;
42+
/// Link coffee to CLN configuration file
43+
async fn link(&mut self, cln_conf_path: &str) -> Result<(), CoffeeError>;
4544

4645
/// show the README file of the plugin
4746
async fn show(&mut self, plugin: &str) -> Result<CoffeeShow, CoffeeError>;

coffee_plugin/src/plugin/plugin_mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn on_init(plugin: &mut Plugin<State>) -> Value {
6464
}
6565
let coffee = coffee.unwrap();
6666
plugin.state.set_coffee(coffee);
67-
plugin.state.setup().await
67+
plugin.state.link().await
6868
});
6969

7070
if let Err(err) = result {

coffee_plugin/src/plugin/state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ impl State {
4141
self.args.clone().unwrap()
4242
}
4343

44-
pub async fn setup(&self) -> Result<(), CoffeeError> {
44+
pub async fn link(&self) -> Result<(), CoffeeError> {
4545
self.coffee()
4646
.lock()
4747
.unwrap()
48-
.setup(&self.args.clone().unwrap().conf)
48+
.link(&self.args.clone().unwrap().conf)
4949
.await?;
5050
Ok(())
5151
}

docs/docs-book/src/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ In fact, you can install a Java plugin that supports Coffee in a couple of
3737
commands after you [install it](./install-coffee.md)
3838

3939
```bash
40-
coffee --network testnet setup /home/alice/.lightning
40+
coffee --network testnet link /home/alice/.lightning
4141
coffee --network testnet remote add lightningd https://github.com/lightningd/plugins.git
4242
coffee --network testnet install btcli4j
4343
```

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ By default the Core Lightning home is stored in the `/home/<user>/.lightning`,
1818
and you can do it with the following command
1919

2020
```bash
21-
coffee setup /home/alice/.lightning
21+
coffee link /home/alice/.lightning
2222
```
2323

2424
Then you will find an include at the end of the config file at

0 commit comments

Comments
 (0)