daemon bin: try to detect '--help' or '-h'

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.
This commit is contained in:
Antoine Poinsot 2023-08-10 11:47:55 +02:00
parent 01ce0f179d
commit d4da2bf6b4
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304

View File

@ -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.0/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);
}
@ -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();
}