- for (i = 0; i < ARRAY_SIZE (commands); i++) {
- command = &commands[i];
-
- if (strcmp (argv[opt_index], command->name) == 0) {
- int ret;
- char *talloc_report;
-
- ret = (command->function)(local, argc - opt_index, argv + opt_index);
-
- talloc_report = getenv ("NOTMUCH_TALLOC_REPORT");
-
- /* this relies on the previous call to
- * talloc_enable_null_tracking */
-
- if (talloc_report && strcmp (talloc_report, "") != 0) {
- FILE *report = fopen (talloc_report, "w");
- if (report) {
- talloc_report_full (NULL, report);
- } else {
- ret = 1;
- fprintf (stderr, "ERROR: unable to write talloc log. ");
- perror (talloc_report);
- }
- }
+ command = find_command (argv[opt_index]);
+ if (!command) {
+ fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n",
+ argv[opt_index]);
+ return 1;
+ }