aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2024-05-29 08:08:36 +0000
committerOmar Polo <op@omarpolo.com>2024-05-29 08:08:36 +0000
commit2f4926259fd27bc7532c67222eb7148c310accb2 (patch)
tree1beec67a467c9b284d4ec83d3af729d91e3651f3
parentcd12ad1132f5560e11c7f1e6f2d436edafbd2641 (diff)
gg: add -q to avoid printing "Server says"
-rw-r--r--gg.14
-rw-r--r--gg.c15
2 files changed, 14 insertions, 5 deletions
diff --git a/gg.1 b/gg.1
index 22fc793..e76fe71 100644
--- a/gg.1
+++ b/gg.1
@@ -20,7 +20,7 @@
.Sh SYNOPSIS
.Nm
.Bk -words
-.Op Fl 23Nn
+.Op Fl 23Nnq
.Op Fl C Ar cert
.Op Fl d Ar mode
.Op Fl H Ar sni
@@ -82,6 +82,8 @@ and
to do the request instead of the ones extracted by the IRI.
.Ar port
is by default 1965.
+.It Fl q
+Don't print server error messages to standard error.
.It Fl T Ar seconds
Kill
.Nm
diff --git a/gg.c b/gg.c
index 9dfd826..c162a30 100644
--- a/gg.c
+++ b/gg.c
@@ -41,6 +41,7 @@ int flag3;
int nop;
int redirects = 5;
int timer;
+int quiet;
const char *cert;
const char *key;
const char *proxy_host;
@@ -308,8 +309,11 @@ get(const char *r)
assert(t != NULL);
if (code < 20 || code >= 30) {
*t = '\0';
- fprintf(stderr, "Server says: ");
- safeprint(stderr, buf + 3); /* skip return code */
+ if (!quiet) {
+ fprintf(stderr, "Server says: ");
+ /* skip return code */
+ safeprint(stderr, buf + 3);
+ }
}
t += 2; /* skip \r\n */
len -= t - buf;
@@ -335,7 +339,7 @@ static void __attribute__((noreturn))
usage(void)
{
fprintf(stderr, "version: " GG_STRING "\n");
- fprintf(stderr, "usage: %s [-23Nn] [-C cert] [-d mode] [-H sni] "
+ fprintf(stderr, "usage: %s [-23Nnq] [-C cert] [-d mode] [-H sni] "
"[-K key] [-P host[:port]]\n",
getprogname());
fprintf(stderr, " [-T seconds] gemini://...\n");
@@ -385,7 +389,7 @@ main(int argc, char **argv)
setlocale(LC_CTYPE, "");
- while ((ch = getopt(argc, argv, "23C:d:H:K:NP:T:")) != -1) {
+ while ((ch = getopt(argc, argv, "23C:d:H:K:NP:qT:")) != -1) {
switch (ch) {
case '2':
flag2 = 1;
@@ -415,6 +419,9 @@ main(int argc, char **argv)
parse_proxy(optarg);
dont_verify_name = 1;
break;
+ case 'q':
+ quiet = 1;
+ break;
case 'T':
timer = strtonum(optarg, 1, 1000, &errstr);
if (errstr != NULL)