From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id OD5BNOPaQGALUwAA0tVLHw (envelope-from ) for ; Thu, 04 Mar 2021 13:04:35 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id yLIYMOPaQGAQIgAA1q6Kng (envelope-from ) for ; Thu, 04 Mar 2021 13:04:35 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5A60922215 for ; Thu, 4 Mar 2021 14:04:35 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 0901427C8A; Thu, 4 Mar 2021 08:02:39 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 6DBAC27558 for ; Thu, 4 Mar 2021 08:02:09 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id 653565FA96; Thu, 4 Mar 2021 08:02:09 -0500 (EST) Received: (nullmailer pid 4047183 invoked by uid 1000); Thu, 04 Mar 2021 13:01:45 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 10/27] CLI: load merged config at top level Date: Thu, 4 Mar 2021 09:01:22 -0400 Message-Id: <20210304130139.4046183-11-david@tethera.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210304130139.4046183-1-david@tethera.net> References: <20210304130139.4046183-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: SCVVA5OM5VPWD7JBYFZNL4VQHW2MLAET X-Message-ID-Hash: SCVVA5OM5VPWD7JBYFZNL4VQHW2MLAET 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-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1614863075; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=KCN5RYYU47yN6kCqTfo1XLni23tOA6vApH7DA1EoQj4=; b=gxs/+uLxP1mHSOVxB2Kr2tfNe+1lbhtlbC6m8VikjiSydt543ezJ9Ll0CdUAgvfWByZaJP oe65PUYOsebFkrSEoLkrrXBeYjfXInRZLSTcwUAivXYrTwGBZqoMD0OY04/xUM02/gWkCF VMnWuHkTRjqRvWwC/2gBULa8VMKtL16nTDeqzd6C8r5v5DVRVK45JAxsOOSAsgsWNNAmt2 LcL4KAQ5BdoecH/djAAYaOvG1h/VlpVBnmPBgbLR9RjH1SJ4PbRvSOY6BSoKn4Dz80FKo0 WjkAuK8rRsRUy/QgCp8zveHX8GD0ici0gplL3lr/deFO+aLTPgecJlv/mxvoSA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1614863075; a=rsa-sha256; cv=none; b=ca8kD1Z0Pe8IizIeyisl+moAM06UqmcFl4OuaBl0g83Bhv9o+fobFqfw14NltXrd62QdJM ttBhZfvLu8ecrCBU4q/BwfP8mpcyPvoT4QlLBVCw2rPjzMwHA535/InbgiYe+W4pwJ+uJt Cc62ZMq6xSjrzyJ2YZ40Zu3D/UDDJ0Xkr3IbMMVAjmcDHOwUK1oSlf2gQEXcM4ikZIZy3e zc510mWVWNf7uDLprM9HuCFq0chBlHL5OnC+xCUrjE65eehprFbz8DNuhbDGjU/H0DdTgw H9iOJWxcqlpeXdG8syzFVeZ9kB+CAD/tNiviv798qR4gDQgFPK00QmipU8x1Ug== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -0.96 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 5A60922215 X-Spam-Score: -0.96 X-Migadu-Scanner: scn0.migadu.com X-TUID: 3E/EllG2XocU This paves the way for the conversion of the remaining subcommands to the new configuration framework. --- notmuch-client.h | 1 + notmuch.c | 29 ++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/notmuch-client.h b/notmuch-client.h index f60f5406..db88daf8 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -258,6 +258,7 @@ typedef enum { NOTMUCH_COMMAND_DATABASE_EARLY = 1 << 2, NOTMUCH_COMMAND_DATABASE_WRITE = 1 << 3, NOTMUCH_COMMAND_DATABASE_CREATE = 1 << 4, + NOTMUCH_COMMAND_CONFIG_LOAD = 1 << 5, } notmuch_command_mode_t; notmuch_config_t * diff --git a/notmuch.c b/notmuch.c index 71482e43..d2eb5daa 100644 --- a/notmuch.c +++ b/notmuch.c @@ -168,7 +168,7 @@ static command_t commands[] = { "Compact the notmuch database." }, { "reindex", notmuch_reindex_command, NOTMUCH_COMMAND_DATABASE_EARLY | NOTMUCH_COMMAND_DATABASE_WRITE, "Re-index all messages matching the search terms." }, - { "config", notmuch_config_command, NOTMUCH_COMMAND_CONFIG_OPEN, + { "config", notmuch_config_command, NOTMUCH_COMMAND_CONFIG_OPEN | NOTMUCH_COMMAND_CONFIG_LOAD, "Get or set settings in the notmuch configuration file." }, #if WITH_EMACS { "emacs-mua", NULL, 0, @@ -460,7 +460,7 @@ main (int argc, char *argv[]) notmuch_config_t *config = NULL; notmuch_database_t *notmuch = NULL; int opt_index; - int ret; + int ret = EXIT_SUCCESS; notmuch_opt_desc_t options[] = { { .opt_string = &config_file_name, .name = "config" }, @@ -548,7 +548,30 @@ main (int argc, char *argv[]) return EXIT_FAILURE; } } - } else { + } + + if (command->mode & NOTMUCH_COMMAND_CONFIG_LOAD) { + char *status_string = NULL; + notmuch_status_t status; + status = notmuch_database_load_config (NULL, + config_file_name, + NULL, + ¬much, + &status_string); + if (status) { + if (status_string) { + fputs (status_string, stderr); + free (status_string); + } + + if (status == NOTMUCH_STATUS_NO_CONFIG) + fputs ("Try running 'notmuch setup' to create a configuration.", stderr); + goto DONE; + } + + } + + if (command->mode & NOTMUCH_COMMAND_CONFIG_OPEN) { config = notmuch_config_open (local, config_file_name, command->mode); if (! config) { ret = EXIT_FAILURE; -- 2.30.1