From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id Ex4BGdi5k2LNYgEAbAwnHQ (envelope-from ) for ; Sun, 29 May 2022 20:22:16 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id MArqF9i5k2L8LQEA9RJhRA (envelope-from ) for ; Sun, 29 May 2022 20:22:16 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3347B39197 for ; Sun, 29 May 2022 20:22:16 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 0AA4A5F527; Sun, 29 May 2022 18:22:13 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 2FBE65E020 for ; Sun, 29 May 2022 18:22:10 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 3DA1C5FBD7; Sun, 29 May 2022 14:22:09 -0400 (EDT) Received: (nullmailer pid 1766086 invoked by uid 1000); Sun, 29 May 2022 18:22:07 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 1/2] CLI: simplify help command Date: Sun, 29 May 2022 15:22:03 -0300 Message-Id: <20220529182204.1766073-1-david@tethera.net> X-Mailer: git-send-email 2.35.2 MIME-Version: 1.0 Message-ID-Hash: HPUVD7MC6BRYC7CLHO2YDG3Q356NMP5S X-Message-ID-Hash: HPUVD7MC6BRYC7CLHO2YDG3Q356NMP5S 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; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1653848536; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=iHMVCLJrviDipVSt7wbcvYYVSqDR8NcrtEUuGKetWus=; b=o3yigtCcv26PerhD5HJ4+2B8Gg92TpKKhyf8jYtp+lFy3ulpRdeCbOg0UIEDfc0RoFTMMh vUVhgd5nedpmwwm+T9NSjKLKr1EuykwiF1KW712K3Cp0TOqnMOBGjPtE4fhFXgqR0MZgeZ zLFvPaRF8rU2+kjE4podBcLyuZ3toHU+LmXK6QgM/qkt8uGmOhfBdfGIfY/KdiFympyakx oDrWK4BvBwzu+L52zCTIHbFECx64IPy6xc6b+LRchmePlDjcZ0kYBF6T6xjcQc170hKM6T ldwWc2/XsyeAJ5/G/pU0sKtrzCfsePiUT+wkId9Kj8wGPw7KFQJAyDi3+bq5NQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1653848536; a=rsa-sha256; cv=none; b=gAfq/s0x9z+GOgjk4zcCKTC8OUBd/mWHn9onz/tDfa080PONyJ7ywEkuoDk3OEMKJERq1t 6uC+hlRaKsDilqGsRw8NgvyCmQA69pn66ZjHPtwARSimmJBWeAJBIEN4GtveFFALIeyRq9 CiEe279q09v75xKKadunepxq+d/LYSOLR7CtLY6cKVjql2sZa2grcYtU4MLPQ3rToE1Q62 F5a6yScmeuHqqssC0fzJZ1bUuJLjPs3iBQMH4A62OE+LR731+tzH091Y11n+E6zx2ClrO+ JRN3rfmy1GbVi3CNEG0CgZ9X/0sSOJCMoQ/imDovR1AyrTcgvEsKydG5YTQyJw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.03 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 3347B39197 X-Spam-Score: -1.03 X-Migadu-Scanner: scn0.migadu.com X-TUID: YMPDvPNHAVH2 This will allow "notmuch help" to work for arbitrary external commands and for any added non-command topics (such as notmuch-sexp-queries). --- notmuch.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/notmuch.c b/notmuch.c index ac25ae18..c39fcfb2 100644 --- a/notmuch.c +++ b/notmuch.c @@ -329,9 +329,7 @@ exec_man (const char *page) static int _help_for (const char *topic_name) { - const command_t *command; - const help_topic_t *topic; - unsigned int i; + char *page; if (! topic_name) { printf ("The notmuch mail system.\n\n"); @@ -348,23 +346,9 @@ _help_for (const char *topic_name) return EXIT_SUCCESS; } - command = find_command (topic_name); - if (command) { - char *page = talloc_asprintf (NULL, "notmuch-%s", command->name); - exec_man (page); - } - - for (i = 0; i < ARRAY_SIZE (help_topics); i++) { - topic = &help_topics[i]; - if (strcmp (topic_name, topic->name) == 0) { - char *page = talloc_asprintf (NULL, "notmuch-%s", topic->name); - exec_man (page); - } - } + page = talloc_asprintf (NULL, "notmuch-%s", topic_name); + exec_man (page); - fprintf (stderr, - "\nSorry, %s is not a known command. There's not much I can do to help.\n\n", - topic_name); return EXIT_FAILURE; } -- 2.35.2