From: Jani Nikula Date: Fri, 1 Nov 2013 14:27:15 +0000 (+0100) Subject: [PATCH 6/6] cli: add compact --verbose option and silence output without it X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7bb8eb945a2a0fe582d9d30207ba9b2cd582c187;p=notmuch-archives.git [PATCH 6/6] cli: add compact --verbose option and silence output without it --- diff --git a/8a/0e72077c57794c80e6dbe97c4f2b95e3e6c687 b/8a/0e72077c57794c80e6dbe97c4f2b95e3e6c687 new file mode 100644 index 000000000..2d46c40e9 --- /dev/null +++ b/8a/0e72077c57794c80e6dbe97c4f2b95e3e6c687 @@ -0,0 +1,122 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 8955E431FD6 + for ; Fri, 1 Nov 2013 07:28:01 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id c9C3AWAb9bPK for ; + Fri, 1 Nov 2013 07:27:56 -0700 (PDT) +Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com + [209.85.212.176]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 14241431FC9 + for ; Fri, 1 Nov 2013 07:27:47 -0700 (PDT) +Received: by mail-wi0-f176.google.com with SMTP id ex4so1152921wid.15 + for ; Fri, 01 Nov 2013 07:27:47 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references:in-reply-to:references; + bh=vNJlk+TqGnF2CtjKBlGwl8qgV/+yCpn9o1orrMiYDNI=; + b=mPG2koh8rbjn4O8vtQIO2/vvR1+TaxzQfi6V7cxUrXdr4FC/o4mDGHTJqn5TC/z8DZ + rR2hXVMYSAZLfSRLe3pngnpBpSTituIjyGcJTBS2BTvigp4OgbO/LAqeFgmfarpKjwj4 + 4YHIetMLSscEzYdmVzQA2ks98jIx6AVJFrs76RDRRnJHEy0eZSBjc+jpbflYPk9BN2ni + UTU8pMEE87R3Rdrht9Hp2u+oMHs99a8u79baZXW/1rN9OX34rOlmq7VCHlTGEaRcB6F8 + WLX/uXxNo1I2zeTlN8wbX44zLWz87En0aAKoN9LTkKLkQIu+PlbdX2HTkPu3R0NMUOYY + 8DYQ== +X-Gm-Message-State: + ALoCoQmwxXZq7iSrD4dzXEAdvlMm9oPX6ZntCoOeqizkudq5LINq9ojfdD80OrP4hTjS6fXhBhZr +X-Received: by 10.181.11.163 with SMTP id ej3mr2460386wid.47.1383316066997; + Fri, 01 Nov 2013 07:27:46 -0700 (PDT) +Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3]) + by mx.google.com with ESMTPSA id ll10sm6996165wic.9.2013.11.01.07.27.45 + for + (version=TLSv1.1 cipher=RC4-SHA bits=128/128); + Fri, 01 Nov 2013 07:27:46 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH 6/6] cli: add compact --verbose option and silence output + without it +Date: Fri, 1 Nov 2013 15:27:15 +0100 +Message-Id: + +X-Mailer: git-send-email 1.7.2.5 +In-Reply-To: +References: +In-Reply-To: +References: +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 01 Nov 2013 14:28:02 -0000 + +If there's nothing surprising to say, don't say anything. Unless asked +for by the user. +--- + notmuch-compact.c | 16 +++++++++++----- + 1 files changed, 11 insertions(+), 5 deletions(-) + +diff --git a/notmuch-compact.c b/notmuch-compact.c +index ecac86a..c0ae22e 100644 +--- a/notmuch-compact.c ++++ b/notmuch-compact.c +@@ -32,27 +32,33 @@ notmuch_compact_command (notmuch_config_t *config, int argc, char *argv[]) + const char *path = notmuch_config_get_database_path (config); + const char *backup_path = NULL; + notmuch_status_t ret; ++ notmuch_bool_t verbose; + int opt_index; + + notmuch_opt_desc_t options[] = { + { NOTMUCH_OPT_STRING, &backup_path, "backup", 0, 0 }, ++ { NOTMUCH_OPT_BOOLEAN, &verbose, "verbose", 'v', 0 }, + }; + + opt_index = parse_arguments (argc, argv, options, 1); + if (opt_index < 0) + return 1; + +- printf ("Compacting database...\n"); +- ret = notmuch_database_compact (path, backup_path, status_update_cb, NULL); ++ if (verbose) ++ printf ("Compacting database...\n"); ++ ret = notmuch_database_compact (path, backup_path, ++ verbose ? status_update_cb : NULL, NULL); + if (ret) { + fprintf (stderr, "Compaction failed: %s\n", notmuch_status_to_string(ret)); + return 1; + } + +- printf ("Done.\n"); ++ if (verbose) { ++ printf ("Done.\n"); + +- if (backup_path) +- printf ("The old database has been moved to %s.\n", backup_path); ++ if (backup_path) ++ printf ("The old database has been moved to %s.\n", backup_path); ++ } + + return 0; + } +-- +1.7.2.5 +