]> git.notmuchmail.org Git - notmuch/commitdiff
cli: add support for notmuch command --help
authorJani Nikula <jani@nikula.org>
Sun, 8 Mar 2015 16:18:55 +0000 (18:18 +0200)
committerDavid Bremner <david@tethera.net>
Wed, 11 Mar 2015 07:07:55 +0000 (08:07 +0100)
Recognize 'notmuch command --help' at the top level as a special case,
and show help for the command. Note that for simplicity, --help is
only recognized as the first option for the subcommand.

notmuch.c

index 1717e8b3683c485e4652e37abc9886e13d2afa49..a5b2877aee09243044b960d6b3b1f833fbf091af 100644 (file)
--- a/notmuch.c
+++ b/notmuch.c
@@ -314,7 +314,9 @@ main (int argc, char *argv[])
        goto DONE;
     }
 
-    if (print_help) {
+    /* Handle notmuch --help [command] and notmuch command --help. */
+    if (print_help ||
+       (opt_index + 1 < argc && strcmp (argv[opt_index + 1], "--help") == 0)) {
        /*
         * Pass the first positional argument as argv[1] so the help
         * command can give help for it. The help command ignores the