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 13653431FC0
\r
6 for <notmuch@notmuchmail.org>; Sun, 19 Jan 2014 12:33:20 -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 rzCcvvGjV2VT for <notmuch@notmuchmail.org>;
\r
17 Sun, 19 Jan 2014 12:33:14 -0800 (PST)
\r
18 Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com
\r
19 [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
20 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
21 B6A21431FC2 for <notmuch@notmuchmail.org>; Sun, 19 Jan 2014 12:32:52 -0800
\r
23 Received: by mail-ee0-f53.google.com with SMTP id t10so3032743eei.26
\r
24 for <notmuch@notmuchmail.org>; Sun, 19 Jan 2014 12:32:51 -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=D6+aP1uMxK+c/ZCQHQ9Eh2ohBxFQLkC73CpVyS+ltqY=;
\r
30 b=PyHRhlKtzJ9GIjYOEkZfmP71jzfSGJ4qgKCBPd9aVCF9kguXY0Fnhtiw3hkRTOF9nD
\r
31 jb0yr9SpePuqkVNVeZfp8we6A+79ACpecOP5CbtRcO4f0FJmhDzbrKtA8+fdwktVpMAN
\r
32 nuGeQnuo8pKbH7oRkXHzqz7Aset+4t936Y164QE68a+I63xPLtPyiWh4n5/OwvFmcq1f
\r
33 wwxSwlTPqyYyfs2gW9RGKvCH5eWArvCKHR2QbwD3axwy/dG2V2gY29h5gEcJ6op56woK
\r
34 q+wJ7MZK00IuWXANMV/a8WVyEA6ICMrQsVfYAf7mYNPrCISwsYueiYhUtlvriHGDWdu6
\r
37 ALoCoQluG5CPOvlfLZtvpjLunBlKofP5cwr3pioIxaNK3qFMAlT/fkatUC4dYFnrwTa4+F2doidd
\r
38 X-Received: by 10.14.2.73 with SMTP id 49mr14223995eee.15.1390163571572;
\r
39 Sun, 19 Jan 2014 12:32:51 -0800 (PST)
\r
40 Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.
\r
42 by mx.google.com with ESMTPSA id v1sm46527413eef.9.2014.01.19.12.32.50
\r
43 for <multiple recipients>
\r
44 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
45 Sun, 19 Jan 2014 12:32:50 -0800 (PST)
\r
46 From: Jani Nikula <jani@nikula.org>
\r
47 To: notmuch@notmuchmail.org
\r
48 Subject: [PATCH 6/7] cli: add --quiet option to notmuch new
\r
49 Date: Sun, 19 Jan 2014 22:32:27 +0200
\r
51 <276371280dfbf8d98a9970b68910e1c030769641.1390163335.git.jani@nikula.org>
\r
52 X-Mailer: git-send-email 1.8.5.2
\r
53 In-Reply-To: <cover.1390163335.git.jani@nikula.org>
\r
54 References: <cover.1390163335.git.jani@nikula.org>
\r
55 In-Reply-To: <cover.1390163335.git.jani@nikula.org>
\r
56 References: <cover.1390163335.git.jani@nikula.org>
\r
57 X-BeenThere: notmuch@notmuchmail.org
\r
58 X-Mailman-Version: 2.1.13
\r
60 List-Id: "Use and development of the notmuch mail system."
\r
61 <notmuch.notmuchmail.org>
\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
65 List-Post: <mailto:notmuch@notmuchmail.org>
\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
69 X-List-Received-Date: Sun, 19 Jan 2014 20:33:20 -0000
\r
71 Tie it to --verbose (resulting in verbosity levels of quiet, normal,
\r
72 and verbose) but leave --debug orthogonal. Do some drive-by cleaning
\r
75 notmuch-new.c | 47 ++++++++++++++++++++++++++++++++---------------
\r
76 1 file changed, 32 insertions(+), 15 deletions(-)
\r
78 diff --git a/notmuch-new.c b/notmuch-new.c
\r
79 index c443181..cd74489 100644
\r
82 @@ -34,9 +34,15 @@ typedef struct _filename_list {
\r
83 _filename_node_t **tail;
\r
89 + VERBOSITY_VERBOSE,
\r
93 int output_is_a_tty;
\r
94 - notmuch_bool_t verbose;
\r
95 + enum verbosity verbosity;
\r
96 notmuch_bool_t debug;
\r
97 const char **new_tags;
\r
98 size_t new_tags_length;
\r
99 @@ -566,13 +572,11 @@ add_files (notmuch_database_t *notmuch,
\r
101 state->processed_files++;
\r
103 - if (state->verbose) {
\r
104 + if (state->verbosity >= VERBOSITY_VERBOSE) {
\r
105 if (state->output_is_a_tty)
\r
106 printf("\r\033[K");
\r
108 - printf ("%i/%i: %s",
\r
109 - state->processed_files,
\r
110 - state->total_files,
\r
111 + printf ("%i/%i: %s", state->processed_files, state->total_files,
\r
114 putchar((state->output_is_a_tty) ? '\r' : '\n');
\r
115 @@ -741,7 +745,7 @@ count_files (const char *path, int *count, add_files_state_t *state)
\r
116 entry_type = dirent_type (path, entry);
\r
117 if (entry_type == S_IFREG) {
\r
118 *count = *count + 1;
\r
119 - if (*count % 1000 == 0) {
\r
120 + if (*count % 1000 == 0 && state->verbosity >= VERBOSITY_NORMAL) {
\r
121 printf ("Found %d files so far.\r", *count);
\r
124 @@ -917,13 +921,15 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
126 notmuch_bool_t timer_is_active = FALSE;
\r
127 notmuch_bool_t no_hooks = FALSE;
\r
128 + notmuch_bool_t quiet = FALSE, verbose = FALSE;
\r
130 - add_files_state.verbose = FALSE;
\r
131 + add_files_state.verbosity = VERBOSITY_NORMAL;
\r
132 add_files_state.debug = FALSE;
\r
133 add_files_state.output_is_a_tty = isatty (fileno (stdout));
\r
135 notmuch_opt_desc_t options[] = {
\r
136 - { NOTMUCH_OPT_BOOLEAN, &add_files_state.verbose, "verbose", 'v', 0 },
\r
137 + { NOTMUCH_OPT_BOOLEAN, &quiet, "quiet", 'q', 0 },
\r
138 + { NOTMUCH_OPT_BOOLEAN, &verbose, "verbose", 'v', 0 },
\r
139 { NOTMUCH_OPT_BOOLEAN, &add_files_state.debug, "debug", 'd', 0 },
\r
140 { NOTMUCH_OPT_BOOLEAN, &no_hooks, "no-hooks", 'n', 0 },
\r
142 @@ -933,6 +939,12 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
144 return EXIT_FAILURE;
\r
146 + /* quiet trumps verbose */
\r
148 + add_files_state.verbosity = VERBOSITY_QUIET;
\r
149 + else if (verbose)
\r
150 + add_files_state.verbosity = VERBOSITY_VERBOSE;
\r
152 add_files_state.new_tags = notmuch_config_get_new_tags (config, &add_files_state.new_tags_length);
\r
153 add_files_state.new_ignore = notmuch_config_get_new_ignore (config, &add_files_state.new_ignore_length);
\r
154 add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);
\r
155 @@ -954,7 +966,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
157 return EXIT_FAILURE;
\r
159 - printf ("Found %d total files (that's not much mail).\n", count);
\r
160 + if (add_files_state.verbosity >= VERBOSITY_NORMAL)
\r
161 + printf ("Found %d total files (that's not much mail).\n", count);
\r
162 if (notmuch_database_create (db_path, ¬much))
\r
163 return EXIT_FAILURE;
\r
164 add_files_state.total_files = count;
\r
165 @@ -964,11 +977,14 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
166 return EXIT_FAILURE;
\r
168 if (notmuch_database_needs_upgrade (notmuch)) {
\r
169 - printf ("Welcome to a new version of notmuch! Your database will now be upgraded.\n");
\r
170 + if (add_files_state.verbosity >= VERBOSITY_NORMAL)
\r
171 + printf ("Welcome to a new version of notmuch! Your database will now be upgraded.\n");
\r
172 gettimeofday (&add_files_state.tv_start, NULL);
\r
173 - notmuch_database_upgrade (notmuch, upgrade_print_progress,
\r
174 + notmuch_database_upgrade (notmuch,
\r
175 + add_files_state.verbosity >= VERBOSITY_NORMAL ? upgrade_print_progress : NULL,
\r
177 - printf ("Your notmuch database has now been upgraded to database format version %u.\n",
\r
178 + if (add_files_state.verbosity >= VERBOSITY_NORMAL)
\r
179 + printf ("Your notmuch database has now been upgraded to database format version %u.\n",
\r
180 notmuch_database_get_version (notmuch));
\r
183 @@ -999,8 +1015,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
184 add_files_state.removed_directories = _filename_list_create (config);
\r
185 add_files_state.directory_mtimes = _filename_list_create (config);
\r
187 - if (! debugger_is_active () && add_files_state.output_is_a_tty
\r
188 - && ! add_files_state.verbose) {
\r
189 + if (add_files_state.verbosity == VERBOSITY_NORMAL &&
\r
190 + add_files_state.output_is_a_tty && ! debugger_is_active ()) {
\r
191 setup_progress_printing_timer ();
\r
192 timer_is_active = TRUE;
\r
194 @@ -1053,7 +1069,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
195 if (timer_is_active)
\r
196 stop_progress_printing_timer ();
\r
198 - print_results (&add_files_state);
\r
199 + if (add_files_state.verbosity >= VERBOSITY_NORMAL)
\r
200 + print_results (&add_files_state);
\r
203 fprintf (stderr, "Note: A fatal error was encountered: %s\n",
\r