aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-11-27 16:28:48 -0500
committerB. Watson <urchlay@slackware.uk>2025-11-27 16:28:48 -0500
commit68de9dc3de220ab454efe066a805e18358c5f4f2 (patch)
tree4e60e48214e47ca3fdbea5eb59d9034c87d2d840
parent64c29e344ba19c1c5d4b1fd837e2b9a6031d1f11 (diff)
downloadunalf-68de9dc3de220ab454efe066a805e18358c5f4f2.tar.gz
-V/--version option for alf.
-rw-r--r--src/alf.116
-rw-r--r--src/alf.c8
-rw-r--r--src/alf.rst12
3 files changed, 35 insertions, 1 deletions
diff --git a/src/alf.1 b/src/alf.1
index 2266526..82d462b 100644
--- a/src/alf.1
+++ b/src/alf.1
@@ -69,11 +69,27 @@ is made with \fB\-a\fP\&.
.
.INDENT 0.0
.TP
+.B \-h\fP,\fB \-\-help
+Show built\-in help message.
+.UNINDENT
+.\" show this help message.
+.
+.INDENT 0.0
+.TP
.B \-o
Overwrite \fIalf\-file\fP if it exists; do not make a \fB~\fP backup.
.UNINDENT
.\" overwrite alf file if exists (do not create file~ backup).
.
+.INDENT 0.0
+.TP
+.B \-V\fP,\fB \-\-version
+Show \fBunalf\fP version number and exit.
+.UNINDENT
+.\" show version number.
+.
+.\" ENDOPTS
+.
.SH EXIT STATUS
.INDENT 0.0
.TP
diff --git a/src/alf.c b/src/alf.c
index d294378..725b109 100644
--- a/src/alf.c
+++ b/src/alf.c
@@ -357,13 +357,19 @@ int main(int argc, char **argv) {
usage();
}
+ if(!strcmp(argv[1], "--version")) {
+ puts(VERSION);
+ exit(0);
+ }
+
/* don't let getopt() print error message for us. */
opterr = 0;
- while((opt = getopt(argc, argv, "ao")) != -1) {
+ while((opt = getopt(argc, argv, "aoV")) != -1) {
switch(opt) {
case 'a': opt_append = 1; opt_overwrite = 1; break;
case 'o': opt_overwrite = 1; opt_append = 0; break;
+ case 'V': puts(VERSION); exit(0); break;
default:
fprintf(stderr, "%s: fatal: invalid option '-%c' (try -h or --help)\n", self, optopt);
exit(1);
diff --git a/src/alf.rst b/src/alf.rst
index 898efb3..879d0da 100644
--- a/src/alf.rst
+++ b/src/alf.rst
@@ -55,11 +55,23 @@ OPTIONS
.. append to alf file.
+-h, --help
+ Show built-in help message.
+
+.. show this help message.
+
-o
Overwrite *alf-file* if it exists; do not make a **~** backup.
.. overwrite alf file if exists (do not create file~ backup).
+-V, --version
+ Show **unalf** version number and exit.
+
+.. show version number.
+
+.. ENDOPTS
+
EXIT STATUS
===========