Skip to content

Commit

Permalink
Merge pull request #33 from vincenzopalazzo/macros/fix-help-command
Browse files Browse the repository at this point in the history
server: Handle --help command
  • Loading branch information
G8XSU authored Dec 11, 2024
2 parents 9e24e8d + e26e467 commit 40f6bcd
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions ldk-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,33 @@ use hyper_util::rt::TokioIo;

use crate::util::config::load_config;
use ldk_node::config::Config;
use std::fs;
use std::path::Path;
use std::sync::Arc;

const USAGE_GUIDE: &str = "Usage: ldk-server <config_path>";

fn main() {
let args: Vec<String> = std::env::args().collect();

if args.len() < 2 {
eprintln!("Usage: {} config_path", args[0]);
eprintln!("{USAGE_GUIDE}");
std::process::exit(-1);
}

let arg = args[1].as_str();
if arg == "-h" || arg == "--help" {
println!("{}", USAGE_GUIDE);
std::process::exit(0);
}

if fs::File::open(arg).is_err() {
eprintln!("Unable to access configuration file.");
std::process::exit(-1);
}

let mut ldk_node_config = Config::default();
let config_file = load_config(Path::new(&args[1])).expect("Invalid configuration file.");
let config_file = load_config(Path::new(arg)).expect("Invalid configuration file.");

ldk_node_config.log_level = LogLevel::Trace;
ldk_node_config.storage_dir_path = config_file.storage_dir_path;
Expand Down

0 comments on commit 40f6bcd

Please sign in to comment.