From ee835553475f1bef7aa08fe36948ed5b34a49b85 Mon Sep 17 00:00:00 2001 From: Peter Wang Date: Sun, 25 Nov 2012 12:16:34 +1100 Subject: [PATCH] [PATCH v2 08/20] insert: support --folder option --- 0c/e4e95f82c6a28e118b6bb4eea004b87cea1eab | 112 ++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 0c/e4e95f82c6a28e118b6bb4eea004b87cea1eab diff --git a/0c/e4e95f82c6a28e118b6bb4eea004b87cea1eab b/0c/e4e95f82c6a28e118b6bb4eea004b87cea1eab new file mode 100644 index 000000000..dc97911da --- /dev/null +++ b/0c/e4e95f82c6a28e118b6bb4eea004b87cea1eab @@ -0,0 +1,112 @@ +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 89019431FAF + for ; Sat, 24 Nov 2012 17:17:50 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, 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 Spwe83tBZSwW for ; + Sat, 24 Nov 2012 17:17:50 -0800 (PST) +Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com + [209.85.220.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 0B80C431FAE + for ; Sat, 24 Nov 2012 17:17:49 -0800 (PST) +Received: by mail-pa0-f53.google.com with SMTP id hz1so3911431pad.26 + for ; Sat, 24 Nov 2012 17:17:49 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=2NE0FXGC1i2630ICDz8Yy4v0touNs4MaQ4U3C/nmWT8=; + b=YkkKI2mSr1s9bD4PLK5tQJb4lwhiY5WdrWbI9P7UWqMlF1aBw3BRZ7fjyU/S1v2PgR + 2VoU8h93Z2oGSfCWq3dDfRlExNEzyGMnNTIeauAnLioyvqcuRbWXYJm3M0GChcrBDV+T + 9q0VseBVs5kyN+FNDjq4EFXfr2AcHtQPJswpx/A7rSNHRoxc3vVl8zuNJ2gXySO7A0/7 + yyo4wWKkE17z1boiXlNxqV5ZGjUtOjfSPmnBYR8sz7QLcpLyhyYqMh/DrC1/TkZWZNru + vm4jH5rywB+Kosytoiq2cBO16F1yM82Wx6xMWE4n/i99Q7oIGFqQ7AomH7w19UvcPGCI + blGA== +Received: by 10.68.135.101 with SMTP id pr5mr26127731pbb.140.1353806269801; + Sat, 24 Nov 2012 17:17:49 -0800 (PST) +Received: from localhost (215.42.233.220.static.exetel.com.au. + [220.233.42.215]) + by mx.google.com with ESMTPS id mz10sm6225942pbc.37.2012.11.24.17.17.47 + (version=TLSv1/SSLv3 cipher=OTHER); + Sat, 24 Nov 2012 17:17:49 -0800 (PST) +From: Peter Wang +To: notmuch@notmuchmail.org +Subject: [PATCH v2 08/20] insert: support --folder option +Date: Sun, 25 Nov 2012 12:16:34 +1100 +Message-Id: <1353806206-29133-9-git-send-email-novalazy@gmail.com> +X-Mailer: git-send-email 1.7.12.1 +In-Reply-To: <1353806206-29133-1-git-send-email-novalazy@gmail.com> +References: <1353806206-29133-1-git-send-email-novalazy@gmail.com> +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, 25 Nov 2012 01:17:50 -0000 + +Allow the new message to be inserted into a folder within the Maildir +hierarchy instead of the top-level folder. +--- + notmuch-insert.c | 21 ++++++++++++++++++++- + 1 file changed, 20 insertions(+), 1 deletion(-) + +diff --git a/notmuch-insert.c b/notmuch-insert.c +index 020dc29..a50eacc 100644 +--- a/notmuch-insert.c ++++ b/notmuch-insert.c +@@ -230,16 +230,35 @@ notmuch_insert_command (void *ctx, int argc, char *argv[]) + notmuch_config_t *config; + notmuch_database_t *notmuch; + const char *db_path; ++ const char *folder = NULL; + char *maildir; ++ int opt_index; + notmuch_bool_t ret; + ++ notmuch_opt_desc_t options[] = { ++ { NOTMUCH_OPT_STRING, &folder, "folder", 0, 0 }, ++ { NOTMUCH_OPT_END, 0, 0, 0, 0 } ++ }; ++ ++ opt_index = parse_arguments (argc, argv, options, 1); ++ ++ if (opt_index < 0) { ++ fprintf (stderr, "Error: bad argument to notmuch insert: %s\n", ++ argv[-opt_index]); ++ return 1; ++ } ++ + config = notmuch_config_open (ctx, NULL, NULL); + if (config == NULL) + return 1; + + db_path = notmuch_config_get_database_path (config); + +- maildir = talloc_asprintf (ctx, "%s", db_path); ++ if (folder != NULL) { ++ maildir = talloc_asprintf (ctx, "%s/%s", db_path, folder); ++ } else { ++ maildir = talloc_asprintf (ctx, "%s", db_path); ++ } + if (! maildir) { + fprintf (stderr, "Out of memory\n"); + return 1; +-- +1.7.12.1 + -- 2.26.2