1 Return-Path: <jani@nikula.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 14AAD42116D
\r
6 for <notmuch@notmuchmail.org>; Thu, 5 Jan 2012 12:25:29 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
13 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id jMxWmehpqxhb for <notmuch@notmuchmail.org>;
\r
17 Thu, 5 Jan 2012 12:25:27 -0800 (PST)
\r
18 Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com
\r
19 [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
20 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
21 2275F429E3B for <notmuch@notmuchmail.org>; Thu, 5 Jan 2012 12:25:27 -0800
\r
23 Received: by mail-ee0-f53.google.com with SMTP id d41so756745eek.26
\r
24 for <notmuch@notmuchmail.org>; Thu, 05 Jan 2012 12:25:26 -0800 (PST)
\r
25 Received: by 10.14.22.10 with SMTP id s10mr1232481ees.122.1325795126730;
\r
26 Thu, 05 Jan 2012 12:25:26 -0800 (PST)
\r
27 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.
\r
29 by mx.google.com with ESMTPS id s16sm238060005eef.2.2012.01.05.12.25.24
\r
30 (version=SSLv3 cipher=OTHER); Thu, 05 Jan 2012 12:25:25 -0800 (PST)
\r
31 From: Jani Nikula <jani@nikula.org>
\r
32 To: notmuch@notmuchmail.org,
\r
34 Subject: [PATCH 2/4] cli: convert "notmuch reply" to use the new argument
\r
36 Date: Thu, 5 Jan 2012 22:25:13 +0200
\r
38 <74f31cf0b3dc11b365a3838a44f095326d6c9f99.1325794371.git.jani@nikula.org>
\r
39 X-Mailer: git-send-email 1.7.5.4
\r
40 In-Reply-To: <cover.1325794371.git.jani@nikula.org>
\r
41 References: <cover.1325794371.git.jani@nikula.org>
\r
42 In-Reply-To: <cover.1325794371.git.jani@nikula.org>
\r
43 References: <cover.1325794371.git.jani@nikula.org>
\r
44 X-BeenThere: notmuch@notmuchmail.org
\r
45 X-Mailman-Version: 2.1.13
\r
47 List-Id: "Use and development of the notmuch mail system."
\r
48 <notmuch.notmuchmail.org>
\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
52 List-Post: <mailto:notmuch@notmuchmail.org>
\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
56 X-List-Received-Date: Thu, 05 Jan 2012 20:25:29 -0000
\r
58 Use the new notmuch argument parser to handle arguments in "notmuch
\r
59 reply". There should be no functional changes.
\r
61 Signed-off-by: Jani Nikula <jani@nikula.org>
\r
63 notmuch-reply.c | 75 +++++++++++++++++++++++++++----------------------------
\r
64 1 files changed, 37 insertions(+), 38 deletions(-)
\r
66 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
67 index 1f33a86..000f6da 100644
\r
68 --- a/notmuch-reply.c
\r
69 +++ b/notmuch-reply.c
\r
70 @@ -612,62 +612,61 @@ notmuch_reply_format_headers_only(void *ctx,
\r
76 + FORMAT_HEADERS_ONLY,
\r
80 notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
82 notmuch_config_t *config;
\r
83 notmuch_database_t *notmuch;
\r
84 notmuch_query_t *query;
\r
85 - char *opt, *query_string;
\r
87 + char *query_string;
\r
88 + int opt_index, ret = 0;
\r
89 int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params);
\r
90 notmuch_show_params_t params = { .part = -1 };
\r
91 + int format = FORMAT_DEFAULT;
\r
92 + notmuch_bool_t decrypt = FALSE;
\r
94 + notmuch_opt_desc_t options[] = {
\r
95 + { NOTMUCH_OPT_KEYWORD, &format, "format", 'f',
\r
96 + (notmuch_keyword_t []){ { "default", FORMAT_DEFAULT },
\r
97 + { "headers-only", FORMAT_HEADERS_ONLY },
\r
99 + { NOTMUCH_OPT_BOOLEAN, &decrypt, "decrypt", 'd', 0 },
\r
100 + { 0, 0, 0, 0, 0 }
\r
103 - reply_format_func = notmuch_reply_format_default;
\r
105 - argc--; argv++; /* skip subcommand argument */
\r
106 + opt_index = parse_arguments (argc, argv, options, 1);
\r
107 + if (opt_index < 0) {
\r
108 + /* diagnostics already printed */
\r
112 - for (i = 0; i < argc && argv[i][0] == '-'; i++) {
\r
113 - if (strcmp (argv[i], "--") == 0) {
\r
117 - if (STRNCMP_LITERAL (argv[i], "--format=") == 0) {
\r
118 - opt = argv[i] + sizeof ("--format=") - 1;
\r
119 - if (strcmp (opt, "default") == 0) {
\r
120 - reply_format_func = notmuch_reply_format_default;
\r
121 - } else if (strcmp (opt, "headers-only") == 0) {
\r
122 - reply_format_func = notmuch_reply_format_headers_only;
\r
124 - fprintf (stderr, "Invalid value for --format: %s\n", opt);
\r
127 - } else if ((STRNCMP_LITERAL (argv[i], "--decrypt") == 0)) {
\r
128 - if (params.cryptoctx == NULL) {
\r
129 - GMimeSession* session = g_object_new(g_mime_session_get_type(), NULL);
\r
130 - if (NULL == (params.cryptoctx = g_mime_gpg_context_new(session, "gpg"))) {
\r
131 - fprintf (stderr, "Failed to construct gpg context.\n");
\r
133 - params.decrypt = TRUE;
\r
134 - g_mime_gpg_context_set_always_trust((GMimeGpgContext*)params.cryptoctx, FALSE);
\r
136 - g_object_unref (session);
\r
139 + if (format == FORMAT_HEADERS_ONLY)
\r
140 + reply_format_func = notmuch_reply_format_headers_only;
\r
142 + reply_format_func = notmuch_reply_format_default;
\r
145 + GMimeSession* session = g_object_new (g_mime_session_get_type(), NULL);
\r
146 + params.cryptoctx = g_mime_gpg_context_new (session, "gpg");
\r
147 + if (params.cryptoctx) {
\r
148 + g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.cryptoctx, FALSE);
\r
149 + params.decrypt = TRUE;
\r
151 - fprintf (stderr, "Unrecognized option: %s\n", argv[i]);
\r
153 + fprintf (stderr, "Failed to construct gpg context.\n");
\r
155 + g_object_unref (session);
\r
161 config = notmuch_config_open (ctx, NULL, NULL);
\r
162 if (config == NULL)
\r
165 - query_string = query_string_from_args (ctx, argc, argv);
\r
166 + query_string = query_string_from_args (ctx, argc-opt_index, argv+opt_index);
\r
167 if (query_string == NULL) {
\r
168 fprintf (stderr, "Out of memory\n");
\r