summaryrefslogtreecommitdiffstats
path: root/tools
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 /tools
parent3934652aeea8bc5b824d237bbaff648381217db2 (diff)
downloadlibirecovery-a3d690c7772b0a9fe04c4d255e5c06d95f31a4de.tar.gz
libirecovery-a3d690c7772b0a9fe04c4d255e5c06d95f31a4de.tar.bz2
irecovery: Add new "--version" option to output version information
Diffstat (limited to 'tools')
-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 @@
23#include "config.h" 23#include "config.h"
24#endif 24#endif
25 25
26#define TOOL_NAME "irecovery"
27
26#include <stdio.h> 28#include <stdio.h>
27#include <stdlib.h> 29#include <stdlib.h>
28#include <unistd.h> 30#include <unistd.h>
@@ -371,6 +373,7 @@ static void print_usage(int argc, char **argv) {
371 printf(" -q, --query\t\tquery device info\n"); 373 printf(" -q, --query\t\tquery device info\n");
372 printf(" -v, --verbose\t\tenable verbose output, repeat for higher verbosity\n"); 374 printf(" -v, --verbose\t\tenable verbose output, repeat for higher verbosity\n");
373 printf(" -h, --help\t\tprints this usage information\n"); 375 printf(" -h, --help\t\tprints this usage information\n");
376 printf(" -V, --version\t\tprints version information\n");
374 printf("\n"); 377 printf("\n");
375 printf("Homepage: <" PACKAGE_URL ">\n"); 378 printf("Homepage: <" PACKAGE_URL ">\n");
376 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); 379 printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n");
@@ -390,6 +393,7 @@ int main(int argc, char* argv[]) {
390 { "query", no_argument, NULL, 'q' }, 393 { "query", no_argument, NULL, 'q' },
391 { "verbose", no_argument, NULL, 'v' }, 394 { "verbose", no_argument, NULL, 'v' },
392 { "help", no_argument, NULL, 'h' }, 395 { "help", no_argument, NULL, 'h' },
396 { "version", no_argument, NULL, 'V' },
393 { NULL, 0, NULL, 0 } 397 { NULL, 0, NULL, 0 }
394 }; 398 };
395 int i = 0; 399 int i = 0;
@@ -408,7 +412,7 @@ int main(int argc, char* argv[]) {
408 return 0; 412 return 0;
409 } 413 }
410 414
411 while ((opt = getopt_long(argc, argv, "i:vhrsmnc:f:e:k:q", longopts, NULL)) > 0) { 415 while ((opt = getopt_long(argc, argv, "i:vVhrsmnc:f:e:k:q", longopts, NULL)) > 0) {
412 switch (opt) { 416 switch (opt) {
413 case 'i': 417 case 'i':
414 if (optarg) { 418 if (optarg) {
@@ -472,6 +476,10 @@ int main(int argc, char* argv[]) {
472 action = kQueryInfo; 476 action = kQueryInfo;
473 break; 477 break;
474 478
479 case 'V':
480 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
481 return 0;
482
475 default: 483 default:
476 fprintf(stderr, "Unknown argument\n"); 484 fprintf(stderr, "Unknown argument\n");
477 return -1; 485 return -1;