From: Bartosz Golaszewski Date: Fri, 6 Jan 2017 15:22:36 +0000 (+0100) Subject: gpiodetect: add options to the help text X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=d91a515a58b22308d5b8039d79eefcfec727d050;p=qemu-gpiodev%2Flibgpiod.git gpiodetect: add options to the help text Also: move displaying the help message to a separate function. Signed-off-by: Bartosz Golaszewski --- 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());