From e87a9e18f6739988b93b6bc38c1ae178c0bdaeb8 Mon Sep 17 00:00:00 2001 From: Matt Corallo <649246+TheBlueMatt@users.noreply.github.com> Date: Thu, 26 Aug 2021 04:17:59 +0000 Subject: [PATCH] Correctly parse args without port but with net Fixes #33. --- src/cli.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index d4d7e9e..476ea81 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -70,7 +70,10 @@ pub(crate) fn parse_startup_args() -> Result { let mut ldk_peer_port_set = true; let ldk_peer_listening_port: u16 = match env::args().skip(3).next().map(|p| p.parse()) { Some(Ok(p)) => p, - Some(Err(e)) => panic!("{}", e), + Some(Err(_)) => { + ldk_peer_port_set = false; + 9735 + } None => { ldk_peer_port_set = false; 9735 @@ -84,7 +87,9 @@ pub(crate) fn parse_startup_args() -> Result { let network: Network = match env::args().skip(arg_idx).next().as_ref().map(String::as_str) { Some("testnet") => Network::Testnet, Some("regtest") => Network::Regtest, - Some(_) => panic!("Unsupported network provided. Options are: `regtest`, `testnet`"), + Some(net) => { + panic!("Unsupported network provided. Options are: `regtest`, `testnet`. Got {}", net); + } None => Network::Testnet, }; -- 2.39.5