mirror of
https://github.com/ElementsProject/lightning.git
synced 2026-08-14 12:42:57 +02:00
This is the first part of two commits that attempts to simplify
the API that is used to retrieve configuration values.
Previously, we encouraged the following pattern to build a plugin.
```rust
let configured_plugin =
Builder::new(
tokio::io::stdin(),
tokio::io::stdout())
.option(ConfigOption::new_i64_with_default("some-option", 0, "Description"))
.configure();
let value = configured_plugion.option("some-option");
match value {
Some(Integer(i)) => {}, // Config provided
None => {}, // No config set
_ => {}, // This should never happened
}
```
This commit helps to move to the following pattern
```rust
const SOME_OPTION : ConfigOption<i64> = ConfigOption::new_i64_with_default(
"some-option",
"description");
async fn main() -> Result<()> {
let plugin = Builder::new(tokio::io::stdin(), tokio::io::stdoout())
.option(SOME_OPTION)
.configure()
.await?;
let value : i64 = plugin.option(SOME_OPTION)?;
}
```
|
||
|---|---|---|
| .. | ||
| bkpr | ||
| clnrest | ||
| examples | ||
| grpc-plugin | ||
| renepay | ||
| spender | ||
| src | ||
| test | ||
| .gitignore | ||
| autoclean.c | ||
| bcli.c | ||
| Cargo.toml | ||
| chanbackup.c | ||
| commando.c | ||
| fetchinvoice.c | ||
| funder.c | ||
| funder_policy.c | ||
| funder_policy.h | ||
| keysend.c | ||
| libplugin-pay.c | ||
| libplugin-pay.h | ||
| libplugin.c | ||
| libplugin.h | ||
| Makefile | ||
| offers.c | ||
| offers.h | ||
| offers_inv_hook.c | ||
| offers_inv_hook.h | ||
| offers_invreq_hook.c | ||
| offers_invreq_hook.h | ||
| offers_offer.c | ||
| offers_offer.h | ||
| pay.c | ||
| README.md | ||
| sql.c | ||
| topology.c | ||
| txprepare.c | ||
Plugin Directory
Any file in this directory which is executable and whose name only consists of alphanumeric characters, space, '.', '-' or '_' will be automatically loaded when lightningd starts (unless suppressed with commandline options).