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 4D8B5431E64
\r
6 for <notmuch@notmuchmail.org>; Sun, 19 Jan 2014 12:33:09 -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 HUN9YlOFzSmI for <notmuch@notmuchmail.org>;
\r
17 Sun, 19 Jan 2014 12:33:03 -0800 (PST)
\r
18 Received: from mail-ea0-f173.google.com (mail-ea0-f173.google.com
\r
19 [209.85.215.173]) (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 0A500431FC0
\r
22 for <notmuch@notmuchmail.org>; Sun, 19 Jan 2014 12:32:49 -0800 (PST)
\r
23 Received: by mail-ea0-f173.google.com with SMTP id o10so2704189eaj.32
\r
24 for <notmuch@notmuchmail.org>; Sun, 19 Jan 2014 12:32:48 -0800 (PST)
\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
26 d=1e100.net; s=20130820;
\r
27 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
\r
28 :references:in-reply-to:references;
\r
29 bh=GN27nkrca6L387o5tQ5mtCNaTql1AeLIZ3fwHje/bEA=;
\r
30 b=D8Gnnxc6mkIGyR+qSRtA2tnD0juBN4RtPYBLKvmU92ItSnY01bg4GpaPcMzfMZ9EU4
\r
31 2Lu2ERHdpg865Zij1kvBPvc50mYQfED8HPh/44MINJDO4SBv8o6bkmilA6NOvJlF/859
\r
32 kLwSFRLSEQmL/iiwwH3hcYzZmVsNI3hdRaHLjkTq5Uh4zn8cfDZ9nqWdl7nvqbh9Z6TZ
\r
33 mq8BHNpQigOzT76x2/Ssd68GSnLDIaTwGSS2R+epletOITX5inCIlWW/yxQEEFTntZYm
\r
34 PotFkC7RNHmPKIbJFMO3p+WbFW5LNZQsTw/5bOdme8vox4cueTDfQIKyQlUjIjp8JgnU
\r
37 ALoCoQkkNgl+kvYhTmM9tiXIUtvQpPjkzHr6gfImtoXMUIWJdfDssUBEA8lPX4PYa8Ayl4DBdARq
\r
38 X-Received: by 10.15.94.201 with SMTP id bb49mr14162929eeb.45.1390163568893;
\r
39 Sun, 19 Jan 2014 12:32:48 -0800 (PST)
\r
40 Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.
\r
41 [88.195.111.91]) by mx.google.com with ESMTPSA id
\r
42 j46sm46540798eew.18.2014.01.19.12.32.47 for <multiple recipients>
\r
43 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
44 Sun, 19 Jan 2014 12:32:48 -0800 (PST)
\r
45 From: Jani Nikula <jani@nikula.org>
\r
46 To: notmuch@notmuchmail.org
\r
47 Subject: [PATCH 5/7] cli: abstract notmuch new result printing
\r
48 Date: Sun, 19 Jan 2014 22:32:26 +0200
\r
50 <3c2ac7334d0f57b35c7cb53b6231f7a9b325d1b0.1390163335.git.jani@nikula.org>
\r
51 X-Mailer: git-send-email 1.8.5.2
\r
52 In-Reply-To: <cover.1390163335.git.jani@nikula.org>
\r
53 References: <cover.1390163335.git.jani@nikula.org>
\r
54 In-Reply-To: <cover.1390163335.git.jani@nikula.org>
\r
55 References: <cover.1390163335.git.jani@nikula.org>
\r
56 X-BeenThere: notmuch@notmuchmail.org
\r
57 X-Mailman-Version: 2.1.13
\r
59 List-Id: "Use and development of the notmuch mail system."
\r
60 <notmuch.notmuchmail.org>
\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
62 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
64 List-Post: <mailto:notmuch@notmuchmail.org>
\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
68 X-List-Received-Date: Sun, 19 Jan 2014 20:33:09 -0000
\r
70 The notmuch_new_command() function has grown huge, chop it up a
\r
71 bit. This should also be helpful when adding a --quiet option to
\r
72 notmuch new. No functional changes.
\r
74 notmuch-new.c | 80 +++++++++++++++++++++++++++++------------------------------
\r
75 1 file changed, 39 insertions(+), 41 deletions(-)
\r
77 diff --git a/notmuch-new.c b/notmuch-new.c
\r
78 index f6d9c3a..c443181 100644
\r
81 @@ -864,13 +864,49 @@ _remove_directory (void *ctx,
\r
86 +print_results (const add_files_state_t *state)
\r
89 + struct timeval tv_now;
\r
91 + gettimeofday (&tv_now, NULL);
\r
92 + elapsed = notmuch_time_elapsed (state->tv_start, tv_now);
\r
94 + if (state->processed_files) {
\r
95 + printf ("Processed %d %s in ", state->processed_files,
\r
96 + state->processed_files == 1 ? "file" : "total files");
\r
97 + notmuch_time_print_formatted_seconds (elapsed);
\r
99 + printf (" (%d files/sec.).\033[K\n",
\r
100 + (int) (state->processed_files / elapsed));
\r
102 + printf (".\033[K\n");
\r
105 + if (state->added_messages)
\r
106 + printf ("Added %d new %s to the database.", state->added_messages,
\r
107 + state->added_messages == 1 ? "message" : "messages");
\r
109 + printf ("No new mail.");
\r
111 + if (state->removed_messages)
\r
112 + printf (" Removed %d %s.", state->removed_messages,
\r
113 + state->removed_messages == 1 ? "message" : "messages");
\r
115 + if (state->renamed_messages)
\r
116 + printf (" Detected %d file %s.", state->renamed_messages,
\r
117 + state->renamed_messages == 1 ? "rename" : "renames");
\r
123 notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
125 notmuch_database_t *notmuch;
\r
126 add_files_state_t add_files_state;
\r
128 - struct timeval tv_now, tv_start;
\r
129 + struct timeval tv_start;
\r
132 const char *db_path;
\r
133 @@ -1017,45 +1053,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
134 if (timer_is_active)
\r
135 stop_progress_printing_timer ();
\r
137 - gettimeofday (&tv_now, NULL);
\r
138 - elapsed = notmuch_time_elapsed (add_files_state.tv_start,
\r
141 - if (add_files_state.processed_files) {
\r
142 - printf ("Processed %d %s in ", add_files_state.processed_files,
\r
143 - add_files_state.processed_files == 1 ?
\r
144 - "file" : "total files");
\r
145 - notmuch_time_print_formatted_seconds (elapsed);
\r
146 - if (elapsed > 1) {
\r
147 - printf (" (%d files/sec.).\033[K\n",
\r
148 - (int) (add_files_state.processed_files / elapsed));
\r
150 - printf (".\033[K\n");
\r
154 - if (add_files_state.added_messages) {
\r
155 - printf ("Added %d new %s to the database.",
\r
156 - add_files_state.added_messages,
\r
157 - add_files_state.added_messages == 1 ?
\r
158 - "message" : "messages");
\r
160 - printf ("No new mail.");
\r
163 - if (add_files_state.removed_messages) {
\r
164 - printf (" Removed %d %s.",
\r
165 - add_files_state.removed_messages,
\r
166 - add_files_state.removed_messages == 1 ? "message" : "messages");
\r
169 - if (add_files_state.renamed_messages) {
\r
170 - printf (" Detected %d file %s.",
\r
171 - add_files_state.renamed_messages,
\r
172 - add_files_state.renamed_messages == 1 ? "rename" : "renames");
\r
176 + print_results (&add_files_state);
\r
179 fprintf (stderr, "Note: A fatal error was encountered: %s\n",
\r