Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ cargo run --bin ldk-server ./ldk-server/ldk-server-config.toml

Interact with the node using CLI:
```
./target/debug/ldk-server-cli -b localhost:3002 --api-key your-secret-api-key onchain-receive # To generate onchain-receive address.
./target/debug/ldk-server-cli -b localhost:3002 --api-key your-secret-api-key help # To print help/available commands.
ldk-server-cli -b localhost:3002 --api-key your-secret-api-key --tls-cert /path/to/tls_cert.pem onchain-receive # To generate onchain-receive address.
ldk-server-cli -b localhost:3002 --api-key your-secret-api-key --tls-cert /path/to/tls_cert.pem help # To print help/available commands.
```

### Shell Completions

The CLI supports generating shell completions for Bash, Zsh, Fish, Elvish, and PowerShell.

Add completions to your shell config:
```bash
# Bash (add to ~/.bashrc)
eval "$(ldk-server-cli completions bash)"

# Zsh (add to ~/.zshrc)
eval "$(ldk-server-cli completions zsh)"

# Fish (add to ~/.config/fish/config.fish)
ldk-server-cli completions fish | source
```
1 change: 1 addition & 0 deletions ldk-server-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"
[dependencies]
ldk-server-client = { path = "../ldk-server-client", features = ["serde"] }
clap = { version = "4.0.5", default-features = false, features = ["derive", "std", "error-context", "suggestions", "help"] }
clap_complete = { version = "4.0", default-features = false }
hex-conservative = { version = "0.2", default-features = false, features = ["std"] }
tokio = { version = "1.38.0", default-features = false, features = ["rt-multi-thread", "macros"] }
serde = "1.0"
Expand Down
18 changes: 17 additions & 1 deletion ldk-server-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

use std::path::PathBuf;

use clap::{Parser, Subcommand};
use clap::{CommandFactory, Parser, Subcommand};
use clap_complete::{generate, Shell};
use config::{
get_default_api_key_path, get_default_cert_path, get_default_config_path, load_config,
};
Expand Down Expand Up @@ -319,12 +320,26 @@ enum Commands {
)]
cltv_expiry_delta: Option<u32>,
},
#[command(about = "Generate shell completions for the CLI")]
Completions {
#[arg(
value_enum,
help = "The shell to generate completions for (bash, zsh, fish, powershell, elvish)"
)]
shell: Shell,
},
}

#[tokio::main]
async fn main() {
let cli = Cli::parse();

// short-circuit if generating completions
if let Commands::Completions { shell } = cli.command {
generate(shell, &mut Cli::command(), "ldk-server-cli", &mut std::io::stdout());
return;
}

let config_path = cli.config.map(PathBuf::from).or_else(get_default_config_path);
let config = config_path.as_ref().and_then(|p| load_config(p).ok());

Expand Down Expand Up @@ -613,6 +628,7 @@ async fn main() {
.await,
);
},
Commands::Completions { .. } => unreachable!("Handled above"),
}
}

Expand Down