From 91bb5bd0fc5f53d9bf4edb389744b029f9dcf0f9 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Fri, 6 Jan 2017 16:27:47 +0100 Subject: [PATCH] gpiofind: add options to the help text Also: move displaying the help message to a separate function. Signed-off-by: Bartosz Golaszewski --- gpiofind.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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()); -- 2.30.2