From e19daf9aff183820d6ad4f2ec6cfe3b46fd9f7ae Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Sun, 3 Nov 2013 14:24:50 +0200 Subject: [PATCH] [PATCH v2 10/11] cli: add compact --verbose option and silence output without it --- 45/185e2e66dc0e2c0c06370cd50c7d7f6b7a8074 | 123 ++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 45/185e2e66dc0e2c0c06370cd50c7d7f6b7a8074 diff --git a/45/185e2e66dc0e2c0c06370cd50c7d7f6b7a8074 b/45/185e2e66dc0e2c0c06370cd50c7d7f6b7a8074 new file mode 100644 index 000000000..7f5654dda --- /dev/null +++ b/45/185e2e66dc0e2c0c06370cd50c7d7f6b7a8074 @@ -0,0 +1,123 @@ +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 EBF34431FDA + for ; Sun, 3 Nov 2013 04:26:16 -0800 (PST) +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 gprnyPHfA4T5 for ; + Sun, 3 Nov 2013 04:26:10 -0800 (PST) +Received: from mail-ea0-f172.google.com (mail-ea0-f172.google.com + [209.85.215.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 4157B431FAF + for ; Sun, 3 Nov 2013 04:25:21 -0800 (PST) +Received: by mail-ea0-f172.google.com with SMTP id r16so2911479ead.31 + for ; Sun, 03 Nov 2013 04:25:20 -0800 (PST) +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=lE4fv1b5SUE5rbOPhOJQcOWPRNonmPzs1hBc0zd36Ew=; + b=hYaP0Sa1xUUH3yE99t3cdr2CbHll0/SMDyW5qTbgm6newvM690htJ37W2pKVtiC7RN + 2GzsH9AKZcbIjmbSVgO9GbvU47tSYTmBxUrQBxuOfW3IkSyblzzhSCqY69iwnKNtN1fs + dvr7AkbCjfd1H5TpOwS+JGHP39oFo7dxL9zQ5RcJWYaJ7RzENR1g5mVt5c4lzTKCJ3SL + KREUX5toE0B+VymF3IYG+lvkt6+AyIrWTrKjaXE9D92jHRcpMb9FbxgSdxA6iqWVi7on + GV7kDIixqJ4gUoadMs+hdnaaD2C0HPUphNFh3YvmVKOeTID7p6ureBwU4y4XDbuwn8Y+ + XkQA== +X-Gm-Message-State: + ALoCoQn+acWHJ9UXX+iFihwB2/yUzDyY7Nu9zBufH0LQKAWptdTC5zSvlRc/GtCr+v9mP+M29RBw +X-Received: by 10.15.99.72 with SMTP id bk48mr12722679eeb.22.1383481519991; + Sun, 03 Nov 2013 04:25:19 -0800 (PST) +Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. + [88.195.111.91]) + by mx.google.com with ESMTPSA id k7sm32796672eeg.13.2013.11.03.04.25.18 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sun, 03 Nov 2013 04:25:19 -0800 (PST) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH v2 10/11] cli: add compact --verbose option and silence output + without it +Date: Sun, 3 Nov 2013 14:24:50 +0200 +Message-Id: + <3d33996df44b338847dac930b6cd294c57b6e54b.1383481295.git.jani@nikula.org> +X-Mailer: git-send-email 1.8.4.rc3 +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: Sun, 03 Nov 2013 12:26:17 -0000 + +If there's nothing surprising to say, don't say anything. Unless asked +for by the user. +--- + notmuch-compact.c | 16 +++++++++++----- + 1 file changed, 11 insertions(+), 5 deletions(-) + +diff --git a/notmuch-compact.c b/notmuch-compact.c +index 359acfc..1e7808c 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; + } + +- if (backup_path) +- printf ("The old database has been moved to %s.\n", backup_path); ++ if (verbose) { ++ if (backup_path) ++ printf ("The old database has been moved to %s.\n", backup_path); + +- printf ("Done.\n"); ++ printf ("Done.\n"); ++ } + + return 0; + } +-- +1.8.4.rc3 + -- 2.26.2