From 1996c5da86aa6d9740f60719a25bf9c9b5750df6 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Fri, 13 Jan 2017 15:36:49 +0100 Subject: [PATCH] tools: add the --version argument Signed-off-by: Bartosz Golaszewski --- gpiodetect.c | 9 +++++++-- gpiofind.c | 9 +++++++-- gpioget.c | 7 ++++++- gpioinfo.c | 9 +++++++-- gpiomon.c | 7 ++++++- gpioset.c | 7 ++++++- 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/gpiodetect.c b/gpiodetect.c index c35b618..507605a 100644 --- a/gpiodetect.c +++ b/gpiodetect.c @@ -16,11 +16,12 @@ #include 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: diff --git a/gpiofind.c b/gpiofind.c index 0d1e5ce..f390672 100644 --- a/gpiofind.c +++ b/gpiofind.c @@ -16,11 +16,12 @@ #include 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: diff --git a/gpioget.c b/gpioget.c index f82ddde..41ccb9c 100644 --- a/gpioget.c +++ b/gpioget.c @@ -17,11 +17,12 @@ 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; diff --git a/gpioinfo.c b/gpioinfo.c index 2d88e62..8609b77 100644 --- a/gpioinfo.c +++ b/gpioinfo.c @@ -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: diff --git a/gpiomon.c b/gpiomon.c index f2ba13b..54da482 100644 --- a/gpiomon.c +++ b/gpiomon.c @@ -18,11 +18,12 @@ 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; diff --git a/gpioset.c b/gpioset.c index d74d59b..825e4a2 100644 --- a/gpioset.c +++ b/gpioset.c @@ -17,11 +17,12 @@ 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; -- 2.30.2