gpiodetect: add options to the help text
authorBartosz Golaszewski <bartekgola@gmail.com>
Fri, 6 Jan 2017 15:22:36 +0000 (16:22 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Fri, 6 Jan 2017 15:22:36 +0000 (16:22 +0100)
Also: move displaying the help message to a separate function.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
gpiodetect.c

index a5b87f37bd9c29bc5f7e824b8ff65ab710debcae..26e7dabbcd7e9b70cca427b60d2ad2ac2a17d6f4 100644 (file)
@@ -22,6 +22,14 @@ static const struct option longopts[] = {
 
 static const char *const shortopts = "+h";
 
+static void print_help(void)
+{
+       printf("Usage: %s <options>\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());