File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -15,19 +15,33 @@ use hyper_util::rt::TokioIo;
1515
1616use crate :: util:: config:: load_config;
1717use ldk_node:: config:: Config ;
18+ use std:: fs;
1819use std:: path:: Path ;
1920use std:: sync:: Arc ;
2021
22+ const USAGE_GUIDE : & str = "Usage: ldk-server <config_path>" ;
23+
2124fn main ( ) {
2225 let args: Vec < String > = std:: env:: args ( ) . collect ( ) ;
2326
2427 if args. len ( ) < 2 {
25- eprintln ! ( "Usage: {} config_path" , args[ 0 ] ) ;
28+ eprintln ! ( "{USAGE_GUIDE}" ) ;
29+ std:: process:: exit ( -1 ) ;
30+ }
31+
32+ let arg = args[ 1 ] . as_str ( ) ;
33+ if arg == "-h" || arg == "--help" {
34+ println ! ( "{}" , USAGE_GUIDE ) ;
35+ std:: process:: exit ( 0 ) ;
36+ }
37+
38+ if fs:: File :: open ( arg) . is_err ( ) {
39+ eprintln ! ( "Unable to access configuration file." ) ;
2640 std:: process:: exit ( -1 ) ;
2741 }
2842
2943 let mut ldk_node_config = Config :: default ( ) ;
30- let config_file = load_config ( Path :: new ( & args [ 1 ] ) ) . expect ( "Invalid configuration file." ) ;
44+ let config_file = load_config ( Path :: new ( arg ) ) . expect ( "Invalid configuration file." ) ;
3145
3246 ldk_node_config. log_level = LogLevel :: Trace ;
3347 ldk_node_config. storage_dir_path = config_file. storage_dir_path ;
You can’t perform that action at this time.
0 commit comments