Commit Diff


commit - 64923c4b5e7b04f634d578539ccbe12d34d63995
commit + dc7619245dfed3a4b315225e08e20016fa51919b
blob - 84f636fb62d9845169224dd2c4160fb1d95aa06c
blob + 35ed1fc0b58d95616cdff9e3ec506daed556ab1a
--- telescope.1
+++ telescope.1
@@ -20,7 +20,7 @@
 .Sh SYNOPSIS
 .Nm
 .Bk -words
-.Op Fl hn
+.Op Fl hnv
 .Op Fl c Pa config
 .Op Ar URL
 .Ek
@@ -32,8 +32,8 @@ It is able to process text/gemini and more in general 
 also features tabs, bookmarks and out-of-band TOFU verification.
 .Pp
 The arguments are as follows:
-.Bl -tag -width tenletters
-.It Fl h
+.Bl -tag -width xxxxxxxxxxxxx
+.It Fl h , Fl -help
 Display version and usage.
 .It Fl n
 Configtest mode.
@@ -43,6 +43,8 @@ Specify an alternative configuration file.
 By default
 .Pa $HOME/.telescope/config
 is loaded.
+.It Fl v , Fl -version
+Display version.
 .El
 .Sh TOFU
 .Nm
blob - fd35a63325dd30c4aeb327a6d15f21273aa30761
blob + 8d35fc4661b3de028d157dd30c33f1d6c924a3cb
--- telescope.c
+++ telescope.c
@@ -1,6 +1,7 @@
 #include <sys/socket.h>
 
 #include <errno.h>
+#include <getopt.h>
 #include <limits.h>
 #include <signal.h>
 #include <stdio.h>
@@ -13,6 +14,14 @@
 #include "parser.h"
 #include "telescope.h"
 #include "ui.h"
+
+static struct option longopts[] = {
+	{"help",	no_argument,	NULL,	'h'},
+	{"version",	no_argument,	NULL,	'v'},
+	{NULL,		0,		NULL,	0},
+};
+
+static const char *opts = "c:hnT:v";
 
 static struct imsgev	*iev_fs, *iev_net;
 
@@ -729,7 +738,8 @@ ui_send_fs(int type, uint32_t peerid, const void *data
 static void __attribute__((noreturn))
 usage(int r)
 {
-	fprintf(stderr, "USAGE: %s [-hn] [-c config] [url]\n", getprogname());
+	fprintf(stderr, "USAGE: %s [-hnv] [-c config] [url]\n",
+	    getprogname());
 	fprintf(stderr, "version: " PACKAGE " " VERSION "\n");
 	exit(r);
 }
@@ -758,7 +768,7 @@ main(int argc, char * const *argv)
 	strlcpy(path, getenv("HOME"), sizeof(path));
 	strlcat(path, "/.telescope/config", sizeof(path));
 
-	while ((ch = getopt(argc, argv, "c:hnT:")) != -1) {
+	while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) {
 		switch (ch) {
 		case 'c':
 			fail = 1;
@@ -782,6 +792,10 @@ main(int argc, char * const *argv)
 				    *optarg);
 			}
 			break;
+		case 'v':
+			printf("%s %s\n", PACKAGE_NAME, PACKAGE_VERSION);
+			exit(0);
+			break;
 		default:
 			usage(1);
 		}