Skip to content

Commit b9d6b04

Browse files
committed
Add base cli setup.
1 parent e453109 commit b9d6b04

3 files changed

Lines changed: 114 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7+
client = { path = "../client" }
8+
clap = { version = "4.0.5", default-features = false, features = ["derive", "std"] }
9+
tokio = { version = "1.38.0", default-features = false, features = ["rt-multi-thread", "macros"] }

cli/src/main.rs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1-
fn main() {
2-
println!("Hello, world!");
1+
use clap::{Parser, Subcommand};
2+
use client::client::LdkNodeServerClient;
3+
use client::protos::OnchainReceiveRequest;
4+
5+
#[derive(Parser, Debug)]
6+
#[command(version, about, long_about = None)]
7+
struct Cli {
8+
#[arg(short, long, default_value = "localhost:3000")]
9+
base_url: String,
10+
11+
#[command(subcommand)]
12+
command: Commands,
13+
}
14+
15+
#[derive(Subcommand, Debug)]
16+
enum Commands {
17+
OnchainReceive,
18+
}
19+
20+
#[tokio::main]
21+
async fn main() {
22+
let cli = Cli::parse();
23+
let client = LdkNodeServerClient::new(cli.base_url);
24+
25+
match cli.command {
26+
Commands::OnchainReceive => {
27+
match client.onchain_receive(OnchainReceiveRequest {}).await {
28+
Ok(response) => {
29+
println!("New Bitcoin Address: {:?}", response);
30+
},
31+
Err(e) => {
32+
eprintln!("Error in OnchainReceive: {:?}", e);
33+
},
34+
};
35+
},
36+
}
337
}

0 commit comments

Comments
 (0)