tools: add the --version argument
authorBartosz Golaszewski <bartekgola@gmail.com>
Fri, 13 Jan 2017 14:36:49 +0000 (15:36 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Fri, 13 Jan 2017 14:38:08 +0000 (15:38 +0100)
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
gpiodetect.c
gpiofind.c
gpioget.c
gpioinfo.c
gpiomon.c
gpioset.c

index c35b61835d25e4fd63fb6a3be5589a3c9ff9b499..507605afb7bcbdc48c5e123b169cdc397e432465 100644 (file)
 #include <getopt.h>
 
 static const struct option longopts[] = {
-       { "help", no_argument, NULL, 'h' },
+       { "help",       no_argument,    NULL,   'h' },
+       { "version",    no_argument,    NULL,   'v' },
        { 0 },
 };
 
-static const char *const shortopts = "+h";
+static const char *const shortopts = "+hv";
 
 static void print_help(void)
 {
@@ -28,6 +29,7 @@ static void print_help(void)
        printf("List all GPIO chips\n");
        printf("Options:\n");
        printf("  -h, --help:\t\tdisplay this message and exit\n");
+       printf("  -v, --version:\tdisplay the version and exit\n");
 }
 
 int main(int argc, char **argv)
@@ -47,6 +49,9 @@ int main(int argc, char **argv)
                case 'h':
                        print_help();
                        return EXIT_SUCCESS;
+               case 'v':
+                       print_version();
+                       return EXIT_SUCCESS;
                case '?':
                        die("try %s --help", get_progname());
                default:
index 0d1e5cedf9d6c349c76697ad88b527a9d6b723d7..f390672e3999bfca5f3ea7abc2c924a805f75f3e 100644 (file)
 #include <getopt.h>
 
 static const struct option longopts[] = {
-       { "help", no_argument, NULL, 'h' },
+       { "help",       no_argument,    NULL,   'h' },
+       { "version",    no_argument,    NULL,   'v' },
        { 0 },
 };
 
-static const char *const shortopts = "+h";
+static const char *const shortopts = "+hv";
 
 static void print_help(void)
 {
@@ -28,6 +29,7 @@ static void print_help(void)
        printf("Find a GPIO line by name.\n");
        printf("Options:\n");
        printf("  -h, --help:\t\tdisplay this message and exit\n");
+       printf("  -v, --version:\tdisplay the version and exit\n");
 }
 
 int main(int argc, char **argv)
@@ -47,6 +49,9 @@ int main(int argc, char **argv)
                case 'h':
                        print_help();
                        return EXIT_SUCCESS;
+               case 'v':
+                       print_version();
+                       return EXIT_SUCCESS;
                case '?':
                        die("try %s --help", get_progname());
                default:
index f82dddef67d6dbd059b27fb7c7bd46b651a6f2b6..41ccb9c4308d1049a84e2b36d65771cda5654de8 100644 (file)
--- a/gpioget.c
+++ b/gpioget.c
 
 static const struct option longopts[] = {
        { "help",       no_argument,    NULL,   'h' },
+       { "version",    no_argument,    NULL,   'v' },
        { "active-low", no_argument,    NULL,   'l' },
        { 0 },
 };
 
-static const char *const shortopts = "hl";
+static const char *const shortopts = "hvl";
 
 static void print_help(void)
 {
@@ -30,6 +31,7 @@ static void print_help(void)
        printf("Read value from a GPIO line\n");
        printf("Options:\n");
        printf("  -h, --help:\t\tdisplay this message and exit\n");
+       printf("  -v, --version:\tdisplay the version and exit\n");
        printf("  -l, --active-low:\tset the line active state to low\n");
 }
 
@@ -51,6 +53,9 @@ int main(int argc, char **argv)
                case 'h':
                        print_help();
                        return EXIT_SUCCESS;
+               case 'v':
+                       print_version();
+                       return EXIT_SUCCESS;
                case 'l':
                        active_low = true;
                        break;
index 2d88e62bf7700b1cd46acb7b77bf0c905479ba24..8609b77c515806f12005bbde8d0084bee67f86ff 100644 (file)
@@ -40,11 +40,12 @@ static const struct flag flags[] = {
 };
 
 static const struct option longopts[] = {
-       { "help", no_argument, NULL, 'h' },
+       { "help",       no_argument,    NULL,   'h' },
+       { "version",    no_argument,    NULL,   'v' },
        { 0 },
 };
 
-static const char *const shortopts = "+h";
+static const char *const shortopts = "+hv";
 
 static void print_help(void)
 {
@@ -52,6 +53,7 @@ static void print_help(void)
        printf("List all lines of a GPIO chip.\n");
        printf("Options:\n");
        printf("  -h, --help:\t\tdisplay this message and exit\n");
+       printf("  -v, --version:\tdisplay the version and exit\n");
 }
 
 static PRINTF(3, 4) void prinfo(bool *overflow,
@@ -166,6 +168,9 @@ int main(int argc, char **argv)
                case 'h':
                        print_help();
                        return EXIT_SUCCESS;
+               case 'v':
+                       print_version();
+                       return EXIT_SUCCESS;
                case '?':
                        die("try %s --help", get_progname());
                default:
index f2ba13b9d6cd70d231971a4e11d5d4c09411af24..54da4826c351811189480c653d1c9f9253f1c402 100644 (file)
--- a/gpiomon.c
+++ b/gpiomon.c
 
 static const struct option longopts[] = {
        { "help",       no_argument,    NULL,   'h' },
+       { "version",    no_argument,    NULL,   'v' },
        { "active-low", no_argument,    NULL,   'l' },
        { 0 },
 };
 
-static const char *const shortopts = "hl";
+static const char *const shortopts = "hvl";
 
 static void print_help(void)
 {
@@ -31,6 +32,7 @@ static void print_help(void)
        printf("Wait for events on a GPIO line\n");
        printf("Options:\n");
        printf("  -h, --help:\t\tdisplay this message and exit\n");
+       printf("  -v, --version:\tdisplay the version and exit\n");
        printf("  -l, --active-low:\tset the line active state to low\n");
 }
 
@@ -86,6 +88,9 @@ int main(int argc, char **argv)
                case 'h':
                        print_help();
                        return EXIT_SUCCESS;
+               case 'v':
+                       print_version();
+                       return EXIT_SUCCESS;
                case 'l':
                        active_low = true;
                        break;
index d74d59bf594809b658bd14dc0f4690e6c3bab689..825e4a23ef8f8d30d90477d07ba7f568ef7a75b6 100644 (file)
--- a/gpioset.c
+++ b/gpioset.c
 
 static const struct option longopts[] = {
        { "help",               no_argument,            NULL,   'h' },
+       { "version",    no_argument,    NULL,   'v' },
        { "active-low",         no_argument,            NULL,   'l' },
        { 0 },
 };
 
-static const char *const shortopts = "hl";
+static const char *const shortopts = "hvl";
 
 static void print_help(void)
 {
@@ -30,6 +31,7 @@ static void print_help(void)
        printf("Set value of a GPIO line\n");
        printf("Options:\n");
        printf("  -h, --help:\t\tdisplay this message and exit\n");
+       printf("  -v, --version:\tdisplay the version and exit\n");
        printf("  -l, --active-low:\tset the line active state to low\n");
        printf("\n");
        printf("This program reserves the GPIO line, sets its value and waits for the user to press ENTER before releasing the line\n");
@@ -58,6 +60,9 @@ int main(int argc, char **argv)
                case 'h':
                        print_help();
                        return EXIT_SUCCESS;
+               case 'v':
+                       print_version();
+                       return EXIT_SUCCESS;
                case 'l':
                        active_low = true;
                        break;