From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id +I59GQG0Ll+GZQAA0tVLHw (envelope-from ) for ; Sat, 08 Aug 2020 14:17:37 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id sNnPFAG0Ll+wJQAAB5/wlQ (envelope-from ) for ; Sat, 08 Aug 2020 14:17:37 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E2CCE9403D6 for ; Sat, 8 Aug 2020 14:17:36 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 4754729AD2; Sat, 8 Aug 2020 10:17:15 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 4C9E92711D for ; Sat, 8 Aug 2020 10:17:09 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 421AF5FA66; Sat, 8 Aug 2020 10:17:09 -0400 (EDT) Received: (nullmailer pid 1124297 invoked by uid 1000); Sat, 08 Aug 2020 14:17:04 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 19/19] WIP: switch notmuch-show to new config framework Date: Sat, 8 Aug 2020 11:16:53 -0300 Message-Id: <20200808141653.1124111-20-david@tethera.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200808141653.1124111-1-david@tethera.net> References: <20200808141653.1124111-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: ZVIFSNKTM4LQO5AKFCNY2WRWNFACRN5W X-Message-ID-Hash: ZVIFSNKTM4LQO5AKFCNY2WRWNFACRN5W X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: 0.03 X-TUID: T5oUOtL2tuDI --- notmuch-show.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index dd836add..094cd689 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -1234,6 +1234,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) bool entire_thread_set = false; bool single_message; bool unthreaded = FALSE; + char *status_string = NULL; notmuch_opt_desc_t options[] = { { .opt_keyword = &format, .name = "format", .keywords = @@ -1323,7 +1324,20 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) fprintf (stderr, "Warning: --include-html only implemented for format=text, format=json and format=sexp\n"); } - query_string = query_string_from_args (config, argc - opt_index, argv + opt_index); + notmuch_database_mode_t mode = NOTMUCH_DATABASE_MODE_READ_ONLY; + if (params.crypto.decrypt == NOTMUCH_DECRYPT_TRUE) + mode = NOTMUCH_DATABASE_MODE_READ_WRITE; + if (notmuch_database_open_with_config (NULL, + mode, + _notmuch_config_get_path (config), + NULL, + ¬much, + &status_string)) + return EXIT_FAILURE; + + notmuch_exit_if_unmatched_db_uuid (notmuch); + + query_string = query_string_from_args (notmuch, argc - opt_index, argv + opt_index); if (query_string == NULL) { fprintf (stderr, "Out of memory\n"); return EXIT_FAILURE; @@ -1334,15 +1348,6 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) return EXIT_FAILURE; } - notmuch_database_mode_t mode = NOTMUCH_DATABASE_MODE_READ_ONLY; - if (params.crypto.decrypt == NOTMUCH_DECRYPT_TRUE) - mode = NOTMUCH_DATABASE_MODE_READ_WRITE; - if (notmuch_database_open (notmuch_config_get_database_path (config), - mode, ¬much)) - return EXIT_FAILURE; - - notmuch_exit_if_unmatched_db_uuid (notmuch); - query = notmuch_query_create (notmuch, query_string); if (query == NULL) { fprintf (stderr, "Out of memory\n"); -- 2.28.0