summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2020-06-14 22:58:47 +0200
committerGravatar Martin Szulecki2020-06-14 22:58:47 +0200
commita3d690c7772b0a9fe04c4d255e5c06d95f31a4de (patch)
tree7dabbff7ede4e06ad76039c3f8de792ec78ca09b
parent3934652aeea8bc5b824d237bbaff648381217db2 (diff)
downloadlibirecovery-a3d690c7772b0a9fe04c4d255e5c06d95f31a4de.tar.gz
libirecovery-a3d690c7772b0a9fe04c4d255e5c06d95f31a4de.tar.bz2
irecovery: Add new "--version" option to output version information
-rw-r--r--tools/irecovery.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/irecovery.c b/tools/irecovery.c
index fd53925..6df328a 100644
--- a/tools/irecovery.c
+++ b/tools/irecovery.c
@@ -23,6 +23,8 @@
#include "config.h"
#endif
+#define TOOL_NAME "irecovery"
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -371,6 +373,7 @@ static void print_usage(int argc, char **argv) {
printf(" -q, --query\t\tquery device info\n");
printf(" -v, --verbose\t\tenable verbose output, repeat for higher verbosity\n");
printf(" -h, --help\t\tprints this usage information\n");
+ printf(" -V, --version\t\tprints version information\n");
printf("\n");
printf("Homepage: <" PACKAGE_URL ">\n");
printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n");
@@ -390,6 +393,7 @@ int main(int argc, char* argv[]) {
{ "query", no_argument, NULL, 'q' },
{ "verbose", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 }
};
int i = 0;
@@ -408,7 +412,7 @@ int main(int argc, char* argv[]) {
return 0;
}
- while ((opt = getopt_long(argc, argv, "i:vhrsmnc:f:e:k:q", longopts, NULL)) > 0) {
+ while ((opt = getopt_long(argc, argv, "i:vVhrsmnc:f:e:k:q", longopts, NULL)) > 0) {
switch (opt) {
case 'i':
if (optarg) {
@@ -472,6 +476,10 @@ int main(int argc, char* argv[]) {
action = kQueryInfo;
break;
+ case 'V':
+ printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
+ return 0;
+
default:
fprintf(stderr, "Unknown argument\n");
return -1;