mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-02-17 23:53:15 +01:00
CLI: simplify help command
This will allow "notmuch help" to work for arbitrary external commands and for any added non-command topics (such as notmuch-sexp-queries).
This commit is contained in:
parent
3a6b479a73
commit
52470ddfbf
1 changed files with 3 additions and 19 deletions
22
notmuch.c
22
notmuch.c
|
@ -329,9 +329,7 @@ exec_man (const char *page)
|
||||||
static int
|
static int
|
||||||
_help_for (const char *topic_name)
|
_help_for (const char *topic_name)
|
||||||
{
|
{
|
||||||
const command_t *command;
|
char *page;
|
||||||
const help_topic_t *topic;
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
if (! topic_name) {
|
if (! topic_name) {
|
||||||
printf ("The notmuch mail system.\n\n");
|
printf ("The notmuch mail system.\n\n");
|
||||||
|
@ -348,23 +346,9 @@ _help_for (const char *topic_name)
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
command = find_command (topic_name);
|
page = talloc_asprintf (NULL, "notmuch-%s", topic_name);
|
||||||
if (command) {
|
exec_man (page);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue