diff options
| author | B. Watson <urchlay@slackware.uk> | 2025-11-27 16:28:48 -0500 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2025-11-27 16:28:48 -0500 |
| commit | 68de9dc3de220ab454efe066a805e18358c5f4f2 (patch) | |
| tree | 4e60e48214e47ca3fdbea5eb59d9034c87d2d840 | |
| parent | 64c29e344ba19c1c5d4b1fd837e2b9a6031d1f11 (diff) | |
| download | unalf-68de9dc3de220ab454efe066a805e18358c5f4f2.tar.gz | |
-V/--version option for alf.
| -rw-r--r-- | src/alf.1 | 16 | ||||
| -rw-r--r-- | src/alf.c | 8 | ||||
| -rw-r--r-- | src/alf.rst | 12 |
3 files changed, 35 insertions, 1 deletions
@@ -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 @@ -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 =========== |
