From: Bartosz Golaszewski Date: Fri, 6 Jan 2017 15:27:47 +0000 (+0100) Subject: gpiofind: add options to the help text X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=91bb5bd0fc5f53d9bf4edb389744b029f9dcf0f9;p=qemu-gpiodev%2Flibgpiod.git gpiofind: add options to the help text Also: move displaying the help message to a separate function. Signed-off-by: Bartosz Golaszewski --- diff --git a/gpiofind.c b/gpiofind.c index fe714cd..8a276c3 100644 --- a/gpiofind.c +++ b/gpiofind.c @@ -22,6 +22,14 @@ static const struct option longopts[] = { static const char *const shortopts = "+h"; +static void print_help(void) +{ + printf("Usage: %s [NAME]\n", get_progname()); + printf("Find a GPIO line by name.\n"); + printf("Options:\n"); + printf(" -h, --help:\t\tdisplay this message and exit\n"); +} + int main(int argc, char **argv) { struct gpiod_line *line; @@ -37,8 +45,7 @@ int main(int argc, char **argv) switch (optc) { case 'h': - printf("Usage: %s [NAME]\n", get_progname()); - printf("Find a GPIO line by name.\n"); + print_help(); exit(EXIT_SUCCESS); case '?': die("try %s --help", get_progname());