- for (i = 0; i < ARRAY_SIZE (aliases); i++) {
- alias = &aliases[i];
-
- if (strcmp (argv[1], alias->name) == 0)
- {
- int substitutions;
-
- argv_local = talloc_size (local, sizeof (char *) *
- (argc + MAX_ALIAS_SUBSTITUTIONS - 1));
- if (argv_local == NULL) {
- fprintf (stderr, "Out of memory.\n");
- return 1;
- }
-
- /* Copy all substution arguments from the alias. */
- argv_local[0] = argv[0];
- for (j = 0; j < MAX_ALIAS_SUBSTITUTIONS; j++) {
- if (alias->substitutions[j] == NULL)
- break;
- argv_local[j+1] = alias->substitutions[j];
- }
- substitutions = j;
-
- /* And copy all original arguments (skipping the argument
- * that matched the alias of course. */
- for (j = 2; j < (unsigned) argc; j++) {
- argv_local[substitutions+j-1] = argv[j];
- }
-
- argc += substitutions - 1;
- argv = (char **) argv_local;
- }
+ /* 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
+ * argv[0] passed to it.
+ */
+ ret = notmuch_help_command (NULL, argc - opt_index + 1,
+ argv + opt_index - 1);
+ goto DONE;