aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-12-11 02:04:13 -0500
committerB. Watson <urchlay@slackware.uk>2025-12-11 02:04:13 -0500
commit8ebb60fad72c581b8df71501786807c779903bf7 (patch)
treee2b41703badd93cd1a8979e51732403d66874d1e
parentd9dec8222e1d23323efe8be7a2045b6d1ecf4d4c (diff)
downloadalftools-8ebb60fad72c581b8df71501786807c779903bf7.tar.gz
alf: Add -q (quiet) option.
-rw-r--r--src/alf.111
-rw-r--r--src/alf.c20
-rw-r--r--src/alf.rst7
-rw-r--r--src/alfusage.c1
4 files changed, 31 insertions, 8 deletions
diff --git a/src/alf.1 b/src/alf.1
index fd9fae8..5a3df8f 100644
--- a/src/alf.1
+++ b/src/alf.1
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
-.TH "ALF" 1 "2025-12-10" "0.4.0" "Urchlay's Atari 8-bit Tools"
+.TH "ALF" 1 "2025-12-11" "0.4.0" "Urchlay's Atari 8-bit Tools"
.SH NAME
alf \- create Atari 8-bit ALF archives
.\" RST source for alf(1) man page. Convert with:
@@ -101,6 +101,15 @@ Overwrite \fIalf\-file\fP if it exists; do not make a \fB~\fP backup.
.
.INDENT 0.0
.TP
+.B \-q
+Quiet operation. \fBalf\fP won\(aqt print any messages on standard
+output. Errors and warnings will still be printed to standard
+error.
+.UNINDENT
+.\" quiet.
+.
+.INDENT 0.0
+.TP
.B \fB\-td\fP
Use default \fBLZ.COM\fP timestamps (8 Dec 82 12:24).
.UNINDENT
diff --git a/src/alf.c b/src/alf.c
index 8af01c3..09f1d76 100644
--- a/src/alf.c
+++ b/src/alf.c
@@ -21,6 +21,7 @@ int opt_alftime = 0;
int opt_gmtime = 0;
int opt_txtconv = 0;
int opt_verbose = 0;
+int opt_quiet = 0;
int backup_msg = 0;
int file_count = 0;
@@ -220,13 +221,15 @@ void crunch_file(const char *filename_arg) {
fclose(in_file);
create_header();
- if(opt_verbose) {
- printf("Crunching %s as %s", in_filename, hdr_filename);
- } else {
- printf("Crunching %s", hdr_filename);
+ if(!opt_quiet) {
+ if(opt_verbose) {
+ printf("Crunching %s as %s", in_filename, hdr_filename);
+ } else {
+ printf("Crunching %s", hdr_filename);
+ }
+ fflush(stdout);
+ if(!opt_verbose) putchar('\n');
}
- fflush(stdout);
- if(!opt_verbose) putchar('\n');
/* crunches the entire input to memory! */
crunch();
@@ -316,11 +319,12 @@ int main(int argc, char **argv) {
/* don't let getopt() print error message for us. */
opterr = 0;
- while((opt = getopt(argc, argv, "aAt:ovV")) != -1) {
+ while((opt = getopt(argc, argv, "aAt:oqvV")) != -1) {
switch(opt) {
case 'A': opt_txtconv = 1; break;
case 'a': opt_append = 1; opt_overwrite = 1; break;
case 'o': opt_overwrite = 1; opt_append = 0; break;
+ case 'q': opt_quiet = 1; break;
case 't': opt_zerotime = opt_alftime = opt_gmtime = 0;
switch(*optarg) {
case 'z': opt_zerotime = 1; break;
@@ -339,6 +343,8 @@ int main(int argc, char **argv) {
}
}
+ if(opt_quiet) opt_verbose = 0;
+
if(optind >= argc) {
fprintf(stderr, "%s: fatal: missing alf file argument (try -h or --help)\n", self);
exit(1);
diff --git a/src/alf.rst b/src/alf.rst
index a80b89a..dbee22b 100644
--- a/src/alf.rst
+++ b/src/alf.rst
@@ -81,6 +81,13 @@ an error; **-vtd** is OK).
.. overwrite ALF file if it exists (don't create file~ backup).
+-q
+ Quiet operation. **alf** won't print any messages on standard
+ output. Errors and warnings will still be printed to standard
+ error.
+
+.. quiet.
+
**-td**
Use default **LZ.COM** timestamps (8 Dec 82 12:24).
diff --git a/src/alfusage.c b/src/alfusage.c
index 5c49d88..a3eb8f5 100644
--- a/src/alfusage.c
+++ b/src/alfusage.c
@@ -3,6 +3,7 @@ const char *usage_msg[] = {
" -A: convert EOLs and tabs in all input files.",
" -h: show this help message.",
" -o: overwrite ALF file if it exists (don't create file~ backup).",
+ " -q: quiet.",
" -td: use default LZ.COM timestamps.",
" -tu: use UTC timestamps.",
" -tz: use zero timestamps.",