- if (stat (next, st)) {
- fprintf (stderr, "Error reading %s: %s\n",
- next, strerror (errno));
- ret = NOTMUCH_STATUS_FILE_ERROR;
- continue;
- }
-
- if (S_ISREG (st->st_mode)) {
- /* If the file hasn't been modified since the last
- * add_files, then we need not look at it. */
- if (st->st_mtime > path_dbtime) {
- state->processed_files++;
-
- status = notmuch_database_add_message (notmuch, next);
- switch (status) {
- /* success */
- case NOTMUCH_STATUS_SUCCESS:
- state->added_messages++;
- break;
- /* Non-fatal issues (go on to next file) */
- case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
- /* Stay silent on this one. */
- break;
- case NOTMUCH_STATUS_FILE_NOT_EMAIL:
- fprintf (stderr, "Note: Ignoring non-mail file: %s\n",
- next);
- break;
- /* Fatal issues. Don't process anymore. */
- case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
- fprintf (stderr, "A Xapian error was encountered. Halting processing.\n");
- ret = status;
- goto DONE;
- default:
- fprintf (stderr, "Internal error: add_message returned unexpected value: %d\n", status);
- ret = status;
- goto DONE;
- }
- if (state->processed_files % 1000 == 0)
- add_files_print_progress (state);
- }
- } else if (S_ISDIR (st->st_mode)) {
- status = add_files_recursive (notmuch, next, st, state);
- if (status && ret == NOTMUCH_STATUS_SUCCESS)
- ret = status;
- }
+static command_t commands[] = {
+ { NULL, notmuch_command, NOTMUCH_CONFIG_OPEN | NOTMUCH_CONFIG_CREATE,
+ "Notmuch main command." },
+ { "setup", notmuch_setup_command, NOTMUCH_CONFIG_OPEN | NOTMUCH_CONFIG_CREATE,
+ "Interactively set up notmuch for first use." },
+ { "new", notmuch_new_command, NOTMUCH_CONFIG_OPEN,
+ "Find and import new messages to the notmuch database." },
+ { "insert", notmuch_insert_command, NOTMUCH_CONFIG_OPEN,
+ "Add a new message into the maildir and notmuch database." },
+ { "search", notmuch_search_command, NOTMUCH_CONFIG_OPEN,
+ "Search for messages matching the given search terms." },
+ { "address", notmuch_address_command, NOTMUCH_CONFIG_OPEN,
+ "Get addresses from messages matching the given search terms." },
+ { "show", notmuch_show_command, NOTMUCH_CONFIG_OPEN,
+ "Show all messages matching the search terms." },
+ { "count", notmuch_count_command, NOTMUCH_CONFIG_OPEN,
+ "Count messages matching the search terms." },
+ { "reply", notmuch_reply_command, NOTMUCH_CONFIG_OPEN,
+ "Construct a reply template for a set of messages." },
+ { "tag", notmuch_tag_command, NOTMUCH_CONFIG_OPEN,
+ "Add/remove tags for all messages matching the search terms." },
+ { "dump", notmuch_dump_command, NOTMUCH_CONFIG_OPEN,
+ "Create a plain-text dump of the tags for each message." },
+ { "restore", notmuch_restore_command, NOTMUCH_CONFIG_OPEN,
+ "Restore the tags from the given dump file (see 'dump')." },
+ { "compact", notmuch_compact_command, NOTMUCH_CONFIG_OPEN,
+ "Compact the notmuch database." },
+ { "reindex", notmuch_reindex_command, NOTMUCH_CONFIG_OPEN,
+ "Re-index all messages matching the search terms." },
+ { "config", notmuch_config_command, NOTMUCH_CONFIG_OPEN,
+ "Get or set settings in the notmuch configuration file." },
+#if WITH_EMACS
+ { "emacs-mua", NULL, 0,
+ "send mail with notmuch and emacs." },
+#endif
+ { "help", notmuch_help_command, NOTMUCH_CONFIG_CREATE, /* create but don't save config */
+ "This message, or more detailed help for the named command." }
+};