Skip to content

Commit

Permalink
cli: add global arguments for connecting to lnd
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitalturtle committed Feb 1, 2024
1 parent ab8b68b commit b3a7462
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec = "config_spec.toml"
[dependencies]
async-trait = "0.1.66"
bitcoin = { version = "0.30.2", features = ["rand"] }
clap = { version = "4.4.6", features = ["derive"] }
clap = { version = "4.4.6", features = ["derive", "string"] }
futures = "0.3.26"
home = "0.5.5"
lightning = { version = "0.0.120", features = ["max_level_trace"] }
Expand Down
43 changes: 43 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,54 @@
use clap::{Parser, Subcommand};
use lndk::lndk_offers::decode;
use std::ffi::OsString;

fn get_cert_path_default() -> OsString {
home::home_dir()
.unwrap()
.as_path()
.join(".lnd")
.join("tls.cert")
.into_os_string()
}

fn get_macaroon_path_default() -> OsString {
home::home_dir()
.unwrap()
.as_path()
.join(".lnd/data/chain/bitcoin/regtest/admin.macaroon")
.into_os_string()
}

/// A cli for interacting with lndk.
#[derive(Debug, Parser)]
#[command(name = "lndk-cli")]
#[command(about = "A cli for interacting with lndk", long_about = None)]
struct Cli {
/// Global variables
#[arg(
short,
long,
global = true,
required = false,
default_value = "regtest"
)]
network: String,

#[arg(short, long, global = true, required = false, default_value = get_cert_path_default())]
tls_cert: String,

#[arg(short, long, global = true, required = false, default_value = get_macaroon_path_default())]
macaroon: String,

#[arg(
short,
long,
global = true,
required = false,
default_value = "https://localhost:10009"
)]
address: String,

#[command(subcommand)]
command: Commands,
}
Expand Down

0 comments on commit b3a7462

Please sign in to comment.