make got and tog accept a --version argument; -V option is a bit obscure prompted by a question from tedu@
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
diff --git a/got/got.1 b/got/got.1
index c37e7ca..3cc5be6 100644
--- a/got/got.1
+++ b/got/got.1
@@ -54,7 +54,7 @@ Global options must precede the command name, and are as follows:
.Bl -tag -width tenletters
.It Fl h
Display usage information and exit immediately.
-.It Fl V
+.It Fl V, -version
Display program version and exit immediately.
.El
.Pp
diff --git a/got/got.c b/got/got.c
index 9949c54..38d9e61 100644
--- a/got/got.c
+++ b/got/got.c
@@ -36,6 +36,7 @@
#include <time.h>
#include <paths.h>
#include <regex.h>
+#include <getopt.h>
#include "got_version.h"
#include "got_error.h"
@@ -176,10 +177,14 @@ main(int argc, char *argv[])
unsigned int i;
int ch;
int hflag = 0, Vflag = 0;
+ static struct option longopts[] = {
+ { "version", no_argument, NULL, 'V' },
+ { NULL, 0, NULL, 0}
+ };
setlocale(LC_CTYPE, "");
- while ((ch = getopt(argc, argv, "hV")) != -1) {
+ while ((ch = getopt_long(argc, argv, "hV", longopts, NULL)) != -1) {
switch (ch) {
case 'h':
hflag = 1;
diff --git a/tog/tog.1 b/tog/tog.1
index 19ba4d6..8bb9658 100644
--- a/tog/tog.1
+++ b/tog/tog.1
@@ -68,7 +68,7 @@ Global options must precede the command name, and are as follows:
.Bl -tag -width tenletters
.It Fl h
Display usage information.
-.It Fl V
+.It Fl V, -version
Display program version and exit immediately.
.El
.Pp
diff --git a/tog/tog.c b/tog/tog.c
index f743343..7c13005 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -5099,10 +5099,14 @@ main(int argc, char *argv[])
struct tog_cmd *cmd = NULL;
int ch, hflag = 0, Vflag = 0;
char **cmd_argv = NULL;
+ static struct option longopts[] = {
+ { "version", no_argument, NULL, 'V' },
+ { NULL, 0, NULL, 0}
+ };
setlocale(LC_CTYPE, "");
- while ((ch = getopt(argc, argv, "hV")) != -1) {
+ while ((ch = getopt_long(argc, argv, "hV", longopts, NULL)) != -1) {
switch (ch) {
case 'h':
hflag = 1;