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 B7C80431FC2 for ; Wed, 25 Jul 2012 06:43:56 -0700 (PDT) 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 9S8HN-i69rmc for ; Wed, 25 Jul 2012 06:43:56 -0700 (PDT) Received: from mail-yx0-f181.google.com (mail-yx0-f181.google.com [209.85.213.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 3928D431FD7 for ; Wed, 25 Jul 2012 06:43:51 -0700 (PDT) Received: by mail-yx0-f181.google.com with SMTP id l3so889862yen.26 for ; Wed, 25 Jul 2012 06:43:51 -0700 (PDT) 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=osf7d7Be8NNdKdTD1f1xrB/W1Jml6USeT1LOsxw89QU=; b=SxiqiGZVQId2VhWOlsRIiNCCVxJbzWLRur8PLV5+ZzFp+bMgOefW22+ILoOoDhyTZL e+neVwxYJ01XKEF0xs+IraHULIpO6/BE3oubAXQ6sByCHPBoFzaGJ8kZlsw9bx5wSLmU anTw+8GHqw/KikOX+Ni6Yd63Y5WOnS04/yg/18lV90pqj/S7r63KLS0gyGnevDJDur1w zT2qwdbysj+9qVbBRqFcvSPwfjEkwU87GDaVKPxVcWCn/u/O9OuC/d1z1qW9xAkw7n7m xvVxzbcOTPcOm+0+fAe8vlcANxOYZ5rxd7JprWrsdHQggMNYuPt+JkSdfR1m8+i5BlTX vSzw== Received: by 10.66.89.170 with SMTP id bp10mr12801098pab.12.1343223830696; Wed, 25 Jul 2012 06:43:50 -0700 (PDT) Received: from localhost (215.42.233.220.static.exetel.com.au. [220.233.42.215]) by mx.google.com with ESMTPS id ka5sm14412987pbb.37.2012.07.25.06.43.48 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 Jul 2012 06:43:49 -0700 (PDT) From: Peter Wang To: notmuch@notmuchmail.org Subject: [PATCH 07/18] insert: add --folder option Date: Wed, 25 Jul 2012 23:42:36 +1000 Message-Id: <1343223767-9812-7-git-send-email-novalazy@gmail.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1343223767-9812-1-git-send-email-novalazy@gmail.com> References: <1343223767-9812-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: Wed, 25 Jul 2012 13:43:57 -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 files changed, 20 insertions(+), 1 deletions(-) diff --git a/notmuch-insert.c b/notmuch-insert.c index dd449bc..6398618 100644 --- a/notmuch-insert.c +++ b/notmuch-insert.c @@ -207,16 +207,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 (notmuch_database_open (notmuch_config_get_database_path (config), NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much)) -- 1.7.4.4