From d91a515a58b22308d5b8039d79eefcfec727d050 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Fri, 6 Jan 2017 16:22:36 +0100 Subject: [PATCH] gpiodetect: add options to the help text Also: move displaying the help message to a separate function. Signed-off-by: Bartosz Golaszewski --- gpiodetect.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gpiodetect.c b/gpiodetect.c index a5b87f3..26e7dab 100644 --- a/gpiodetect.c +++ b/gpiodetect.c @@ -22,6 +22,14 @@ static const struct option longopts[] = { static const char *const shortopts = "+h"; +static void print_help(void) +{ + printf("Usage: %s \n", get_progname()); + printf("List all GPIO chips\n"); + printf("Options:\n"); + printf(" -h, --help:\t\tdisplay this message and exit\n"); +} + int main(int argc, char **argv) { struct gpiod_chip_iter *iter; @@ -37,8 +45,7 @@ int main(int argc, char **argv) switch (optc) { case 'h': - printf("Usage: %s\n", get_progname()); - printf("List all GPIO chips\n"); + print_help(); exit(EXIT_SUCCESS); case '?': die("try %s --help", get_progname()); -- 2.30.2