Commit dcf81acb authored by Sebastien Gougeaud's avatar Sebastien Gougeaud Committed by Thomas Leibovici
Browse files

phobosd: add a -h/--help option to the parser



Change-Id: I31c587ac0418b9ca342d3dbd72332aa2dfc6f173
Signed-off-by: default avatarSebastien Gougeaud <sebastien.gougeaud@cea.fr>
Reviewed-on: https://cws-fleury.labs.ocre.cea.fr/gerrit/6510


Reviewed-by: Linter
Tested-by: default avatarJenkins s8open_nr <s8open_nr@ccc.ocre.cea.fr>
Reviewed-by: default avatarThomas Leibovici <thomas.leibovici@cea.fr>
parent 9b23e5ee
......@@ -346,9 +346,23 @@ static void sa_sigterm(int signum)
}
/* Argument parsing */
static void print_usage(void)
{
printf("usage: phobosd [--interactive] [--config cfg_file] "
"[--verbose/--quiet] [--syslog]\n"
"\nOptional arguments:\n"
" -i,--interactive execute the daemon in foreground\n"
" -c,--config cfg_file "
"use cfg_file as the daemon configuration file\n"
" -v,--verbose increase verbose level\n"
" -q,--quiet decrease verbose level\n"
" -s,--syslog print the daemon logs to syslog\n");
}
static struct lrs_params parse_args(int argc, char **argv)
{
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"interactive", no_argument, 0, 'i'},
{"config", required_argument, 0, 'c'},
{"verbose", no_argument, 0, 'v'},
......@@ -361,11 +375,14 @@ static struct lrs_params parse_args(int argc, char **argv)
while (1) {
int c;
c = getopt_long(argc, argv, "ic:vqs", long_options, NULL);
c = getopt_long(argc, argv, "hic:vqs", long_options, NULL);
if (c == -1)
break;
switch (c) {
case 'h':
print_usage();
exit(EXIT_SUCCESS);
case 'i':
parm.is_daemon = false;
break;
......@@ -382,6 +399,7 @@ static struct lrs_params parse_args(int argc, char **argv)
parm.use_syslog = true;
break;
default:
print_usage();
exit(EXIT_FAILURE);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment