1 Return-Path: <jani@nikula.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id B5243429E35
\r
6 for <notmuch@notmuchmail.org>; Sun, 13 Nov 2011 14:47:46 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
13 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id NE4nu0Dq5vHM for <notmuch@notmuchmail.org>;
\r
17 Sun, 13 Nov 2011 14:47:46 -0800 (PST)
\r
18 Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com
\r
19 [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 0B752429E21
\r
22 for <notmuch@notmuchmail.org>; Sun, 13 Nov 2011 14:47:45 -0800 (PST)
\r
23 Received: by mail-bw0-f53.google.com with SMTP id q10so6354254bka.26
\r
24 for <notmuch@notmuchmail.org>; Sun, 13 Nov 2011 14:47:45 -0800 (PST)
\r
25 Received: by 10.205.128.19 with SMTP id hc19mr16953500bkc.9.1321224465567;
\r
26 Sun, 13 Nov 2011 14:47:45 -0800 (PST)
\r
27 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.
\r
29 by mx.google.com with ESMTPS id a4sm18095799bkq.13.2011.11.13.14.47.43
\r
30 (version=SSLv3 cipher=OTHER); Sun, 13 Nov 2011 14:47:44 -0800 (PST)
\r
31 From: Jani Nikula <jani@nikula.org>
\r
32 To: notmuch@notmuchmail.org,
\r
34 Subject: [PATCH 4/6] cli: notmuch count: use getopt_long for parsing command
\r
36 Date: Mon, 14 Nov 2011 00:47:24 +0200
\r
38 <dc84dbd22165357093eb70f3ee81c938d478b5b3.1321223343.git.jani@nikula.org>
\r
39 X-Mailer: git-send-email 1.7.5.4
\r
40 In-Reply-To: <cover.1321223343.git.jani@nikula.org>
\r
41 References: <cover.1321223343.git.jani@nikula.org>
\r
42 In-Reply-To: <cover.1321223343.git.jani@nikula.org>
\r
43 References: <cover.1321223343.git.jani@nikula.org>
\r
44 X-BeenThere: notmuch@notmuchmail.org
\r
45 X-Mailman-Version: 2.1.13
\r
47 List-Id: "Use and development of the notmuch mail system."
\r
48 <notmuch.notmuchmail.org>
\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
52 List-Post: <mailto:notmuch@notmuchmail.org>
\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
56 X-List-Received-Date: Sun, 13 Nov 2011 22:47:46 -0000
\r
58 Signed-off-by: Jani Nikula <jani@nikula.org>
\r
60 notmuch-count.c | 33 ++++++++++++++++++---------------
\r
61 1 files changed, 18 insertions(+), 15 deletions(-)
\r
63 diff --git a/notmuch-count.c b/notmuch-count.c
\r
64 index 20ce334..4987ca8 100644
\r
65 --- a/notmuch-count.c
\r
66 +++ b/notmuch-count.c
\r
67 @@ -28,34 +28,37 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
\r
68 notmuch_database_t *notmuch;
\r
69 notmuch_query_t *query;
\r
72 notmuch_bool_t output_messages = TRUE;
\r
74 - argc--; argv++; /* skip subcommand argument */
\r
77 + static struct option options[] = {
\r
78 + { "output", required_argument, NULL, 0 },
\r
79 + { NULL, 0, NULL, 0 },
\r
82 - for (i = 0; i < argc && argv[i][0] == '-'; i++) {
\r
83 - if (strcmp (argv[i], "--") == 0) {
\r
85 + opt = getopt_long (argc, argv, "", options, NULL);
\r
89 - if (STRNCMP_LITERAL (argv[i], "--output=") == 0) {
\r
90 - const char *opt = argv[i] + sizeof ("--output=") - 1;
\r
91 - if (strcmp (opt, "threads") == 0) {
\r
95 + if (strcmp (optarg, "threads") == 0) {
\r
96 output_messages = FALSE;
\r
97 - } else if (strcmp (opt, "messages") == 0) {
\r
98 + } else if (strcmp (optarg, "messages") == 0) {
\r
99 output_messages = TRUE;
\r
101 - fprintf (stderr, "Invalid value for --output: %s\n", opt);
\r
102 + fprintf (stderr, "Invalid value for --output: %s\n", optarg);
\r
106 - fprintf (stderr, "Unrecognized option: %s\n", argv[i]);
\r
118 config = notmuch_config_open (ctx, NULL, NULL);
\r
119 if (config == NULL)
\r