* [PATCH] cli: fix notmuch help additional topics
@ 2014-03-22 13:06 Jani Nikula
2014-03-22 13:17 ` Tomi Ollila
2014-03-28 1:22 ` David Bremner
0 siblings, 2 replies; 3+ messages in thread
From: Jani Nikula @ 2014-03-22 13:06 UTC (permalink / raw)
To: notmuch
The help for hooks was missing.
---
notmuch.c | 40 +++++++++++++++++++++++++++++++++-------
1 file changed, 33 insertions(+), 7 deletions(-)
diff --git a/notmuch.c b/notmuch.c
index b3fa9f378545..dcda0392a094 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -74,6 +74,18 @@ static command_t commands[] = {
"This message, or more detailed help for the named command." }
};
+typedef struct help_topic {
+ const char *name;
+ const char *summary;
+} help_topic_t;
+
+static help_topic_t help_topics[] = {
+ { "search-terms",
+ "Common search term syntax." },
+ { "hooks",
+ "Hooks that will be run before or after certain commands." },
+};
+
static command_t *
find_command (const char *name)
{
@@ -93,6 +105,7 @@ static void
usage (FILE *out)
{
command_t *command;
+ help_topic_t *topic;
unsigned int i;
fprintf (out,
@@ -107,13 +120,22 @@ usage (FILE *out)
command = &commands[i];
if (command->name)
- fprintf (out, " %-11s %s\n", command->name, command->summary);
+ fprintf (out, " %-12s %s\n", command->name, command->summary);
+ }
+
+ fprintf (out, "\n");
+ fprintf (out, "Additional help topics are as follows:\n");
+ fprintf (out, "\n");
+
+ for (i = 0; i < ARRAY_SIZE (help_topics); i++) {
+ topic = &help_topics[i];
+ fprintf (out, " %-12s %s\n", topic->name, topic->summary);
}
fprintf (out, "\n");
fprintf (out,
- "Use \"notmuch help <command>\" for more details on each command\n"
- "and \"notmuch help search-terms\" for the common search-terms syntax.\n\n");
+ "Use \"notmuch help <command or topic>\" for more details "
+ "on each command or topic.\n\n");
}
void
@@ -156,6 +178,8 @@ static int
notmuch_help_command (notmuch_config_t *config, int argc, char *argv[])
{
command_t *command;
+ help_topic_t *topic;
+ unsigned int i;
argc--; argv++; /* Ignore "help" */
@@ -180,10 +204,12 @@ notmuch_help_command (notmuch_config_t *config, int argc, char *argv[])
exec_man (page);
}
- if (strcmp (argv[0], "search-terms") == 0) {
- exec_man ("notmuch-search-terms");
- } else if (strcmp (argv[0], "hooks") == 0) {
- exec_man ("notmuch-hooks");
+ for (i = 0; i < ARRAY_SIZE (help_topics); i++) {
+ topic = &help_topics[i];
+ if (strcmp (argv[0], topic->name) == 0) {
+ char *page = talloc_asprintf (config, "notmuch-%s", topic->name);
+ exec_man (page);
+ }
}
fprintf (stderr,
--
1.9.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] cli: fix notmuch help additional topics
2014-03-22 13:06 [PATCH] cli: fix notmuch help additional topics Jani Nikula
@ 2014-03-22 13:17 ` Tomi Ollila
2014-03-28 1:22 ` David Bremner
1 sibling, 0 replies; 3+ messages in thread
From: Tomi Ollila @ 2014-03-22 13:17 UTC (permalink / raw)
To: Jani Nikula, notmuch
On Sat, Mar 22 2014, Jani Nikula <jani@nikula.org> wrote:
> The help for hooks was missing.
>
> ---
The code changes LGTM.
Tomi
> notmuch.c | 40 +++++++++++++++++++++++++++++++++-------
> 1 file changed, 33 insertions(+), 7 deletions(-)
>
> diff --git a/notmuch.c b/notmuch.c
> index b3fa9f378545..dcda0392a094 100644
> --- a/notmuch.c
> +++ b/notmuch.c
> @@ -74,6 +74,18 @@ static command_t commands[] = {
> "This message, or more detailed help for the named command." }
> };
>
> +typedef struct help_topic {
> + const char *name;
> + const char *summary;
> +} help_topic_t;
> +
> +static help_topic_t help_topics[] = {
> + { "search-terms",
> + "Common search term syntax." },
> + { "hooks",
> + "Hooks that will be run before or after certain commands." },
> +};
> +
> static command_t *
> find_command (const char *name)
> {
> @@ -93,6 +105,7 @@ static void
> usage (FILE *out)
> {
> command_t *command;
> + help_topic_t *topic;
> unsigned int i;
>
> fprintf (out,
> @@ -107,13 +120,22 @@ usage (FILE *out)
> command = &commands[i];
>
> if (command->name)
> - fprintf (out, " %-11s %s\n", command->name, command->summary);
> + fprintf (out, " %-12s %s\n", command->name, command->summary);
> + }
> +
> + fprintf (out, "\n");
> + fprintf (out, "Additional help topics are as follows:\n");
> + fprintf (out, "\n");
> +
> + for (i = 0; i < ARRAY_SIZE (help_topics); i++) {
> + topic = &help_topics[i];
> + fprintf (out, " %-12s %s\n", topic->name, topic->summary);
> }
>
> fprintf (out, "\n");
> fprintf (out,
> - "Use \"notmuch help <command>\" for more details on each command\n"
> - "and \"notmuch help search-terms\" for the common search-terms syntax.\n\n");
> + "Use \"notmuch help <command or topic>\" for more details "
> + "on each command or topic.\n\n");
> }
>
> void
> @@ -156,6 +178,8 @@ static int
> notmuch_help_command (notmuch_config_t *config, int argc, char *argv[])
> {
> command_t *command;
> + help_topic_t *topic;
> + unsigned int i;
>
> argc--; argv++; /* Ignore "help" */
>
> @@ -180,10 +204,12 @@ notmuch_help_command (notmuch_config_t *config, int argc, char *argv[])
> exec_man (page);
> }
>
> - if (strcmp (argv[0], "search-terms") == 0) {
> - exec_man ("notmuch-search-terms");
> - } else if (strcmp (argv[0], "hooks") == 0) {
> - exec_man ("notmuch-hooks");
> + for (i = 0; i < ARRAY_SIZE (help_topics); i++) {
> + topic = &help_topics[i];
> + if (strcmp (argv[0], topic->name) == 0) {
> + char *page = talloc_asprintf (config, "notmuch-%s", topic->name);
> + exec_man (page);
> + }
> }
>
> fprintf (stderr,
> --
> 1.9.0
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cli: fix notmuch help additional topics
2014-03-22 13:06 [PATCH] cli: fix notmuch help additional topics Jani Nikula
2014-03-22 13:17 ` Tomi Ollila
@ 2014-03-28 1:22 ` David Bremner
1 sibling, 0 replies; 3+ messages in thread
From: David Bremner @ 2014-03-28 1:22 UTC (permalink / raw)
To: Jani Nikula, notmuch
Jani Nikula <jani@nikula.org> writes:
> The help for hooks was missing.
pushed.
d
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-03-28 1:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-22 13:06 [PATCH] cli: fix notmuch help additional topics Jani Nikula
2014-03-22 13:17 ` Tomi Ollila
2014-03-28 1:22 ` David Bremner
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).