unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Lars Kellogg-Stedman <lars@seas.harvard.edu>
To: notmuch <notmuch@notmuchmail.org>
Subject: "notmuch help" outputs to stderr?
Date: Tue, 17 Nov 2009 19:58:29 -0500	[thread overview]
Message-ID: <20091118005829.GB25380@dottiness.seas.harvard.edu> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 542 bytes --]

I'm just noticing that 'notmuch help ...' outputs to stderr, which
isn't terribly intuitive.  For example, the obvious invocation:

  notmuch help | less

...isn't terribly helpful.

I've attached a patch that lets usage() take a FILE * argument so that
you can output to stderr in response to usage errors, and stdout in
response to an explicit request.

-- 
Lars Kellogg-Stedman <lars@seas.harvard.edu>
Senior Technologist, Computing and Information Technology
Harvard University School of Engineering and Applied Sciences


[-- Attachment #1.2: notmuch-help.patch --]
[-- Type: text/plain, Size: 1386 bytes --]

diff --git a/notmuch.c b/notmuch.c
index c47e640..a35cb99 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -157,23 +157,23 @@ command_t commands[] = {
 };
 
 static void
-usage (void)
+usage (FILE *out)
 {
     command_t *command;
     unsigned int i;
 
-    fprintf (stderr, "Usage: notmuch <command> [args...]\n");
-    fprintf (stderr, "\n");
-    fprintf (stderr, "Where <command> and [args...] are as follows:\n");
-    fprintf (stderr, "\n");
+    fprintf (out, "Usage: notmuch <command> [args...]\n");
+    fprintf (out, "\n");
+    fprintf (out, "Where <command> and [args...] are as follows:\n");
+    fprintf (out, "\n");
 
     for (i = 0; i < ARRAY_SIZE (commands); i++) {
 	command = &commands[i];
 
-	fprintf (stderr, "\t%s\t%s\n\n", command->name, command->summary);
+	fprintf (out, "\t%s\t%s\n\n", command->name, command->summary);
     }
 
-    fprintf (stderr, "Use \"notmuch help <command>\" for more details on each command.\n\n");
+    fprintf (out, "Use \"notmuch help <command>\" for more details on each command.\n\n");
 }
 
 static int
@@ -183,8 +183,8 @@ notmuch_help_command (unused (void *ctx), int argc, char *argv[])
     unsigned int i;
 
     if (argc == 0) {
-	fprintf (stderr, "The notmuch mail system.\n\n");
-	usage ();
+	fprintf (stdout, "The notmuch mail system.\n\n");
+	usage (stdout);
 	return 0;
     }
 

[-- Attachment #2: Type: application/pgp-signature, Size: 489 bytes --]

             reply	other threads:[~2009-11-18  0:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-18  0:58 Lars Kellogg-Stedman [this message]
2009-11-18  1:01 ` "notmuch help" outputs to stderr? Lars Kellogg-Stedman
2009-11-18 16:29   ` Carl Worth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091118005829.GB25380@dottiness.seas.harvard.edu \
    --to=lars@seas.harvard.edu \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).