aboutsummaryrefslogtreecommitdiff
path: root/gg.c
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 /gg.c
parentcd12ad1132f5560e11c7f1e6f2d436edafbd2641 (diff)
gg: add -q to avoid printing "Server says"
Diffstat (limited to 'gg.c')
-rw-r--r--gg.c15
1 files changed, 11 insertions, 4 deletions
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)