1 Return-Path: <m.walters@qmul.ac.uk>
\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 534EE431FB6
\r
6 for <notmuch@notmuchmail.org>; Fri, 24 Jan 2014 01:00:50 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5
\r
12 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,
\r
13 NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 6wF9L6Ad5Wq1 for <notmuch@notmuchmail.org>;
\r
17 Fri, 24 Jan 2014 01:00:42 -0800 (PST)
\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 51F3E431FAF
\r
22 for <notmuch@notmuchmail.org>; Fri, 24 Jan 2014 01:00:42 -0800 (PST)
\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])
\r
24 by mail2.qmul.ac.uk with esmtp (Exim 4.71)
\r
25 (envelope-from <m.walters@qmul.ac.uk>)
\r
26 id 1W6cch-000615-Uv; Fri, 24 Jan 2014 09:00:38 +0000
\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)
\r
28 by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)
\r
29 (envelope-from <m.walters@qmul.ac.uk>)
\r
30 id 1W6cbo-000263-CM; Fri, 24 Jan 2014 08:59:28 +0000
\r
31 From: Mark Walters <markwalters1009@gmail.com>
\r
32 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org
\r
33 Subject: Re: [PATCH 6/7] cli: add --quiet option to notmuch new
\r
35 <276371280dfbf8d98a9970b68910e1c030769641.1390163335.git.jani@nikula.org>
\r
36 References: <cover.1390163335.git.jani@nikula.org>
\r
37 <276371280dfbf8d98a9970b68910e1c030769641.1390163335.git.jani@nikula.org>
\r
38 User-Agent: Notmuch/0.15.2+484~gfb59956 (http://notmuchmail.org) Emacs/23.4.1
\r
39 (x86_64-pc-linux-gnu)
\r
40 Date: Fri, 24 Jan 2014 08:58:02 +0000
\r
41 Message-ID: <87txctah9h.fsf@qmul.ac.uk>
\r
43 Content-Type: text/plain; charset=us-ascii
\r
44 X-Sender-Host-Address: 93.97.24.31
\r
45 X-QM-Geographic: According to ripencc,
\r
46 this message was delivered by a machine in Britain (UK) (GB).
\r
47 X-QM-SPAM-Info: Sender has good ham record. :)
\r
48 X-QM-Body-MD5: 7898fa3a61acdc79bf063ba117da7861 (of first 20000 bytes)
\r
49 X-SpamAssassin-Score: 0.0
\r
50 X-SpamAssassin-SpamBar: /
\r
51 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
53 spam. We require at least 5.0 points to mark a message as spam.
\r
54 This message scored 0.0 points. Summary of the scoring:
\r
55 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
56 provider * (markwalters1009[at]gmail.com)
\r
57 * 0.0 AWL AWL: From: address is in the auto white-list
\r
58 X-QM-Scan-Virus: ClamAV says the message is clean
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Fri, 24 Jan 2014 09:00:50 -0000
\r
76 I am working my way through this series in a rather random order.
\r
78 I am not sure I like doing the database upgrade with no comment to the
\r
79 user at all. In fact I am not sure I like doing the upgrade without
\r
80 being specifically told to (e.g. it does not give the user a clear chance
\r
81 to backup the database first)
\r
83 What would people think about having a --upgrade-database option to
\r
91 On Sun, 19 Jan 2014, Jani Nikula <jani@nikula.org> wrote:
\r
92 > Tie it to --verbose (resulting in verbosity levels of quiet, normal,
\r
93 > and verbose) but leave --debug orthogonal. Do some drive-by cleaning
\r
96 > notmuch-new.c | 47 ++++++++++++++++++++++++++++++++---------------
\r
97 > 1 file changed, 32 insertions(+), 15 deletions(-)
\r
99 > diff --git a/notmuch-new.c b/notmuch-new.c
\r
100 > index c443181..cd74489 100644
\r
101 > --- a/notmuch-new.c
\r
102 > +++ b/notmuch-new.c
\r
103 > @@ -34,9 +34,15 @@ typedef struct _filename_list {
\r
104 > _filename_node_t **tail;
\r
105 > } _filename_list_t;
\r
107 > +enum verbosity {
\r
108 > + VERBOSITY_QUIET,
\r
109 > + VERBOSITY_NORMAL,
\r
110 > + VERBOSITY_VERBOSE,
\r
114 > int output_is_a_tty;
\r
115 > - notmuch_bool_t verbose;
\r
116 > + enum verbosity verbosity;
\r
117 > notmuch_bool_t debug;
\r
118 > const char **new_tags;
\r
119 > size_t new_tags_length;
\r
120 > @@ -566,13 +572,11 @@ add_files (notmuch_database_t *notmuch,
\r
122 > state->processed_files++;
\r
124 > - if (state->verbose) {
\r
125 > + if (state->verbosity >= VERBOSITY_VERBOSE) {
\r
126 > if (state->output_is_a_tty)
\r
127 > printf("\r\033[K");
\r
129 > - printf ("%i/%i: %s",
\r
130 > - state->processed_files,
\r
131 > - state->total_files,
\r
132 > + printf ("%i/%i: %s", state->processed_files, state->total_files,
\r
135 > putchar((state->output_is_a_tty) ? '\r' : '\n');
\r
136 > @@ -741,7 +745,7 @@ count_files (const char *path, int *count, add_files_state_t *state)
\r
137 > entry_type = dirent_type (path, entry);
\r
138 > if (entry_type == S_IFREG) {
\r
139 > *count = *count + 1;
\r
140 > - if (*count % 1000 == 0) {
\r
141 > + if (*count % 1000 == 0 && state->verbosity >= VERBOSITY_NORMAL) {
\r
142 > printf ("Found %d files so far.\r", *count);
\r
145 > @@ -917,13 +921,15 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
147 > notmuch_bool_t timer_is_active = FALSE;
\r
148 > notmuch_bool_t no_hooks = FALSE;
\r
149 > + notmuch_bool_t quiet = FALSE, verbose = FALSE;
\r
151 > - add_files_state.verbose = FALSE;
\r
152 > + add_files_state.verbosity = VERBOSITY_NORMAL;
\r
153 > add_files_state.debug = FALSE;
\r
154 > add_files_state.output_is_a_tty = isatty (fileno (stdout));
\r
156 > notmuch_opt_desc_t options[] = {
\r
157 > - { NOTMUCH_OPT_BOOLEAN, &add_files_state.verbose, "verbose", 'v', 0 },
\r
158 > + { NOTMUCH_OPT_BOOLEAN, &quiet, "quiet", 'q', 0 },
\r
159 > + { NOTMUCH_OPT_BOOLEAN, &verbose, "verbose", 'v', 0 },
\r
160 > { NOTMUCH_OPT_BOOLEAN, &add_files_state.debug, "debug", 'd', 0 },
\r
161 > { NOTMUCH_OPT_BOOLEAN, &no_hooks, "no-hooks", 'n', 0 },
\r
162 > { 0, 0, 0, 0, 0 }
\r
163 > @@ -933,6 +939,12 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
164 > if (opt_index < 0)
\r
165 > return EXIT_FAILURE;
\r
167 > + /* quiet trumps verbose */
\r
169 > + add_files_state.verbosity = VERBOSITY_QUIET;
\r
170 > + else if (verbose)
\r
171 > + add_files_state.verbosity = VERBOSITY_VERBOSE;
\r
173 > add_files_state.new_tags = notmuch_config_get_new_tags (config, &add_files_state.new_tags_length);
\r
174 > add_files_state.new_ignore = notmuch_config_get_new_ignore (config, &add_files_state.new_ignore_length);
\r
175 > add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);
\r
176 > @@ -954,7 +966,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
178 > return EXIT_FAILURE;
\r
180 > - printf ("Found %d total files (that's not much mail).\n", count);
\r
181 > + if (add_files_state.verbosity >= VERBOSITY_NORMAL)
\r
182 > + printf ("Found %d total files (that's not much mail).\n", count);
\r
183 > if (notmuch_database_create (db_path, ¬much))
\r
184 > return EXIT_FAILURE;
\r
185 > add_files_state.total_files = count;
\r
186 > @@ -964,11 +977,14 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
187 > return EXIT_FAILURE;
\r
189 > if (notmuch_database_needs_upgrade (notmuch)) {
\r
190 > - printf ("Welcome to a new version of notmuch! Your database will now be upgraded.\n");
\r
191 > + if (add_files_state.verbosity >= VERBOSITY_NORMAL)
\r
192 > + printf ("Welcome to a new version of notmuch! Your database will now be upgraded.\n");
\r
193 > gettimeofday (&add_files_state.tv_start, NULL);
\r
194 > - notmuch_database_upgrade (notmuch, upgrade_print_progress,
\r
195 > + notmuch_database_upgrade (notmuch,
\r
196 > + add_files_state.verbosity >= VERBOSITY_NORMAL ? upgrade_print_progress : NULL,
\r
197 > &add_files_state);
\r
198 > - printf ("Your notmuch database has now been upgraded to database format version %u.\n",
\r
199 > + if (add_files_state.verbosity >= VERBOSITY_NORMAL)
\r
200 > + printf ("Your notmuch database has now been upgraded to database format version %u.\n",
\r
201 > notmuch_database_get_version (notmuch));
\r
204 > @@ -999,8 +1015,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
205 > add_files_state.removed_directories = _filename_list_create (config);
\r
206 > add_files_state.directory_mtimes = _filename_list_create (config);
\r
208 > - if (! debugger_is_active () && add_files_state.output_is_a_tty
\r
209 > - && ! add_files_state.verbose) {
\r
210 > + if (add_files_state.verbosity == VERBOSITY_NORMAL &&
\r
211 > + add_files_state.output_is_a_tty && ! debugger_is_active ()) {
\r
212 > setup_progress_printing_timer ();
\r
213 > timer_is_active = TRUE;
\r
215 > @@ -1053,7 +1069,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
216 > if (timer_is_active)
\r
217 > stop_progress_printing_timer ();
\r
219 > - print_results (&add_files_state);
\r
220 > + if (add_files_state.verbosity >= VERBOSITY_NORMAL)
\r
221 > + print_results (&add_files_state);
\r
224 > fprintf (stderr, "Note: A fatal error was encountered: %s\n",
\r
228 > _______________________________________________
\r
229 > notmuch mailing list
\r
230 > notmuch@notmuchmail.org
\r
231 > http://notmuchmail.org/mailman/listinfo/notmuch
\r