[PATCH v2 10/11] cli: add compact --verbose option and silence output without it
authorJani Nikula <jani@nikula.org>
Sun, 3 Nov 2013 12:24:50 +0000 (14:24 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:57:58 +0000 (09:57 -0800)
45/185e2e66dc0e2c0c06370cd50c7d7f6b7a8074 [new file with mode: 0644]

diff --git a/45/185e2e66dc0e2c0c06370cd50c7d7f6b7a8074 b/45/185e2e66dc0e2c0c06370cd50c7d7f6b7a8074
new file mode 100644 (file)
index 0000000..7f5654d
--- /dev/null
@@ -0,0 +1,123 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id EBF34431FDA\r
+       for <notmuch@notmuchmail.org>; Sun,  3 Nov 2013 04:26:16 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id gprnyPHfA4T5 for <notmuch@notmuchmail.org>;\r
+       Sun,  3 Nov 2013 04:26:10 -0800 (PST)\r
+Received: from mail-ea0-f172.google.com (mail-ea0-f172.google.com\r
+       [209.85.215.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 4157B431FAF\r
+       for <notmuch@notmuchmail.org>; Sun,  3 Nov 2013 04:25:21 -0800 (PST)\r
+Received: by mail-ea0-f172.google.com with SMTP id r16so2911479ead.31\r
+       for <notmuch@notmuchmail.org>; Sun, 03 Nov 2013 04:25:20 -0800 (PST)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=1e100.net; s=20130820;\r
+       h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+       :references:in-reply-to:references;\r
+       bh=lE4fv1b5SUE5rbOPhOJQcOWPRNonmPzs1hBc0zd36Ew=;\r
+       b=hYaP0Sa1xUUH3yE99t3cdr2CbHll0/SMDyW5qTbgm6newvM690htJ37W2pKVtiC7RN\r
+       2GzsH9AKZcbIjmbSVgO9GbvU47tSYTmBxUrQBxuOfW3IkSyblzzhSCqY69iwnKNtN1fs\r
+       dvr7AkbCjfd1H5TpOwS+JGHP39oFo7dxL9zQ5RcJWYaJ7RzENR1g5mVt5c4lzTKCJ3SL\r
+       KREUX5toE0B+VymF3IYG+lvkt6+AyIrWTrKjaXE9D92jHRcpMb9FbxgSdxA6iqWVi7on\r
+       GV7kDIixqJ4gUoadMs+hdnaaD2C0HPUphNFh3YvmVKOeTID7p6ureBwU4y4XDbuwn8Y+\r
+       XkQA==\r
+X-Gm-Message-State:\r
+ ALoCoQn+acWHJ9UXX+iFihwB2/yUzDyY7Nu9zBufH0LQKAWptdTC5zSvlRc/GtCr+v9mP+M29RBw\r
+X-Received: by 10.15.99.72 with SMTP id bk48mr12722679eeb.22.1383481519991;\r
+       Sun, 03 Nov 2013 04:25:19 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+       [88.195.111.91])\r
+       by mx.google.com with ESMTPSA id k7sm32796672eeg.13.2013.11.03.04.25.18\r
+       for <multiple recipients>\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Sun, 03 Nov 2013 04:25:19 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 10/11] cli: add compact --verbose option and silence output\r
+       without it\r
+Date: Sun,  3 Nov 2013 14:24:50 +0200\r
+Message-Id:\r
+ <3d33996df44b338847dac930b6cd294c57b6e54b.1383481295.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.8.4.rc3\r
+In-Reply-To: <cover.1383481295.git.jani@nikula.org>\r
+References: <cover.1383481295.git.jani@nikula.org>\r
+In-Reply-To: <cover.1383481295.git.jani@nikula.org>\r
+References: <cover.1383481295.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 03 Nov 2013 12:26:17 -0000\r
+\r
+If there's nothing surprising to say, don't say anything. Unless asked\r
+for by the user.\r
+---\r
+ notmuch-compact.c | 16 +++++++++++-----\r
+ 1 file changed, 11 insertions(+), 5 deletions(-)\r
+\r
+diff --git a/notmuch-compact.c b/notmuch-compact.c\r
+index 359acfc..1e7808c 100644\r
+--- a/notmuch-compact.c\r
++++ b/notmuch-compact.c\r
+@@ -32,27 +32,33 @@ notmuch_compact_command (notmuch_config_t *config, int argc, char *argv[])\r
+     const char *path = notmuch_config_get_database_path (config);\r
+     const char *backup_path = NULL;\r
+     notmuch_status_t ret;\r
++    notmuch_bool_t verbose;\r
+     int opt_index;\r
\r
+     notmuch_opt_desc_t options[] = {\r
+       { NOTMUCH_OPT_STRING, &backup_path, "backup", 0, 0 },\r
++      { NOTMUCH_OPT_BOOLEAN,  &verbose, "verbose", 'v', 0 },\r
+     };\r
\r
+     opt_index = parse_arguments (argc, argv, options, 1);\r
+     if (opt_index < 0)\r
+       return 1;\r
\r
+-    printf ("Compacting database...\n");\r
+-    ret = notmuch_database_compact (path, backup_path, status_update_cb, NULL);\r
++    if (verbose)\r
++      printf ("Compacting database...\n");\r
++    ret = notmuch_database_compact (path, backup_path,\r
++                                  verbose ? status_update_cb : NULL, NULL);\r
+     if (ret) {\r
+       fprintf (stderr, "Compaction failed: %s\n", notmuch_status_to_string(ret));\r
+       return 1;\r
+     }\r
\r
+-    if (backup_path)\r
+-      printf ("The old database has been moved to %s.\n", backup_path);\r
++    if (verbose) {\r
++      if (backup_path)\r
++          printf ("The old database has been moved to %s.\n", backup_path);\r
\r
+-    printf ("Done.\n");\r
++      printf ("Done.\n");\r
++    }\r
\r
+     return 0;\r
+ }\r
+-- \r
+1.8.4.rc3\r
+\r