From: Jani Nikula Date: Wed, 6 Nov 2013 16:38:55 +0000 (+0200) Subject: [PATCH 1/2] cli: add compact --quiet option and silence output with it X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0194cd9c1d1a43c854c3d684b5057b822c329ce8;p=notmuch-archives.git [PATCH 1/2] cli: add compact --quiet option and silence output with it --- diff --git a/92/d61781f5e0f50b75dd78b14c368761ee0e1865 b/92/d61781f5e0f50b75dd78b14c368761ee0e1865 new file mode 100644 index 000000000..9fd4efe8c --- /dev/null +++ b/92/d61781f5e0f50b75dd78b14c368761ee0e1865 @@ -0,0 +1,124 @@ +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 00AA7429E53 + for ; Wed, 6 Nov 2013 08:45:01 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +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 1yeocI8zqEEI for ; + Wed, 6 Nov 2013 08:44:54 -0800 (PST) +Received: from mail-ea0-f177.google.com (mail-ea0-f177.google.com + [209.85.215.177]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 3E32E429E27 + for ; Wed, 6 Nov 2013 08:44:54 -0800 (PST) +Received: by mail-ea0-f177.google.com with SMTP id f15so4999816eak.8 + for ; Wed, 06 Nov 2013 08:44:53 -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; + bh=WV0SNbxxOZ+3pzHFokUvMfxMM2crA/+5gZY0bc1w7os=; + b=mv7IW1bCrjaYsa5eeDop5U6xJ+0KS6ElGE9ugc4gpjR3DyIMnKMLteH0L4wjtltWoA + msFN40ZMdcMzxx/bSjjgS6iU3FSz3I67DM0Ad7xvk4OpotVO1Iy9Uk/wMCXoW525d8uk + GVWmw6w2Bke3G0mOFLm28cv+YnL3Lua7SG+M0LS8tZR8org2oPnhfohI/4vvIt3HjFvq + utgEGUIQeVoUMFLaQL8YjAev8fbGalxZUYheYBtC5iCmgIq2Qkc2DGS/4ZqUIrvr+hB0 + PPKZN5RyLMPQRXR6LH+TZTjlwYmTtWXNDvVTgnosbqsYggNcGYtzMEx8Q+197moIxCl+ + w7Rw== +X-Gm-Message-State: + ALoCoQmrMB47V7pjph6fUFRnKvJKhB/nj+ZzNbETjJ4KEDIr5ONVbVZP8uyaW6pzddV3SdP4ErlZ +X-Received: by 10.14.107.133 with SMTP id o5mr96981eeg.110.1383755939094; + Wed, 06 Nov 2013 08:38:59 -0800 (PST) +Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. + [88.195.111.91]) + by mx.google.com with ESMTPSA id k7sm75805766eeg.13.2013.11.06.08.38.56 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Wed, 06 Nov 2013 08:38:57 -0800 (PST) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH 1/2] cli: add compact --quiet option and silence output with + it +Date: Wed, 6 Nov 2013 18:38:55 +0200 +Message-Id: <1383755936-11862-1-git-send-email-jani@nikula.org> +X-Mailer: git-send-email 1.8.4.rc3 +In-Reply-To: + <3d33996df44b338847dac930b6cd294c57b6e54b.1383481295.git.jani@nikula.org> +References: + <3d33996df44b338847dac930b6cd294c57b6e54b.1383481295.git.jani@nikula.org> +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: Wed, 06 Nov 2013 16:45:02 -0000 + +Provide a way to silence the output. + +--- + +v2: --verbose -> --quiet +--- + notmuch-compact.c | 16 +++++++++++----- + 1 file changed, 11 insertions(+), 5 deletions(-) + +diff --git a/notmuch-compact.c b/notmuch-compact.c +index 359acfc..8022dfe 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 quiet; + int opt_index; + + notmuch_opt_desc_t options[] = { + { NOTMUCH_OPT_STRING, &backup_path, "backup", 0, 0 }, ++ { NOTMUCH_OPT_BOOLEAN, &quiet, "quiet", 'q', 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 (! quiet) ++ printf ("Compacting database...\n"); ++ ret = notmuch_database_compact (path, backup_path, ++ quiet ? NULL : status_update_cb, 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 (! quiet) { ++ 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 +