Skip to content

Commit

Permalink
daemon bin: try to detect '--help' or '-h'
Browse files Browse the repository at this point in the history
It should fall into the "number of args isn't equal to 3" category
anyways, but it's a cheap way of trying to be more helpful.
  • Loading branch information
darosior committed Aug 11, 2023
1 parent 01ce0f1 commit cf1b052
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/bin/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use liana::{config::Config, DaemonHandle};

fn print_help_exit() {
eprintln!("A TOML configuration file is required to run lianad. By default lianad looks for a 'config.toml' file in its data directory. A different one may be provided like so: '--conf <config file path>'.");
eprintln!("A documented sample is available at https://github.com/wizardsardine/liana/blob/607c0abddab2ff5761b371c6020b0793b1a1bc97/contrib/lianad_config_example.toml.");
eprintln!("A documented sample is available at 'contrib/lianad_config_example.toml' in the source tree (https://github.com/wizardsardine/liana/blob/v1.1/contrib/lianad_config_example.toml).");
eprintln!("The default data directory path is a 'liana/' folder in the XDG standard configuration directory for all OSes but Linux ones, where it's '~/.liana/'.");
process::exit(1);
}
Expand All @@ -19,7 +19,10 @@ fn parse_args(args: Vec<String>) -> Option<PathBuf> {
return None;
}

if args.len() != 3 {
let is_help = args
.iter()
.any(|arg| arg.contains("help") || arg.contains("-h"));
if args.len() != 3 || is_help {
print_help_exit();
}

Expand Down

0 comments on commit cf1b052

Please sign in to comment.