From eb9da376d76b48585b3b63b4f91903b54f7abd36 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 6 Nov 2013 18:28:39 +0100 Subject: clients: unify how we invoke getopt_long() Among other things this makes sure we always expose a --version command and show it in the help texts. --- src/delta/delta.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/delta') diff --git a/src/delta/delta.c b/src/delta/delta.c index b3272d916e..4aaf1dfb14 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -431,7 +431,7 @@ static int process_suffix_chop(const char *prefixes, const char *suffix, const c return -EINVAL; } -static void help(void) { +static int help(void) { printf("%s [OPTIONS...] [SUFFIX...]\n\n" "Find overridden configuration files.\n\n" @@ -441,6 +441,8 @@ static void help(void) { " --diff[=1|0] Show a diff when overridden files differ\n" " -t --type=LIST... Only display a selected set of override types\n", program_invocation_short_name); + + return 0; } static int parse_flags(const char *flag_str, int flags) { @@ -482,7 +484,7 @@ static int parse_argv(int argc, char *argv[]) { { "no-pager", no_argument, NULL, ARG_NO_PAGER }, { "diff", optional_argument, NULL, ARG_DIFF }, { "type", required_argument, NULL, 't' }, - { NULL, 0, NULL, 0 } + {} }; int c; @@ -507,9 +509,6 @@ static int parse_argv(int argc, char *argv[]) { arg_no_pager = true; break; - case '?': - return -EINVAL; - case 't': { int f; f = parse_flags(optarg, arg_flags); @@ -538,9 +537,11 @@ static int parse_argv(int argc, char *argv[]) { } break; - default: - log_error("Unknown option code %c", c); + case '?': return -EINVAL; + + default: + assert_not_reached("Unhandled option"); } } -- cgit v1.2.3-54-g00ecf