typedef int (*command_function_t) (notmuch_config_t *config, int argc, char *argv[]);
typedef struct command {
const char *name;
command_function_t function;
notmuch_bool_t create_config;
typedef int (*command_function_t) (notmuch_config_t *config, int argc, char *argv[]);
typedef struct command {
const char *name;
command_function_t function;
notmuch_bool_t create_config;
static command_t commands[] = {
{ NULL, notmuch_command, TRUE,
static command_t commands[] = {
{ NULL, notmuch_command, TRUE,
"Notmuch main command." },
{ "setup", notmuch_setup_command, TRUE,
"Notmuch main command." },
{ "setup", notmuch_setup_command, TRUE,
"Interactively setup notmuch for first use." },
{ "new", notmuch_new_command, FALSE,
"Interactively setup notmuch for first use." },
{ "new", notmuch_new_command, FALSE,
{ "search", notmuch_search_command, FALSE,
{ "search", notmuch_search_command, FALSE,
"Search for messages matching the given search terms." },
{ "show", notmuch_show_command, FALSE,
"Search for messages matching the given search terms." },
{ "show", notmuch_show_command, FALSE,
"Show all messages matching the search terms." },
{ "count", notmuch_count_command, FALSE,
"Show all messages matching the search terms." },
{ "count", notmuch_count_command, FALSE,
"Count messages matching the search terms." },
{ "reply", notmuch_reply_command, FALSE,
"Count messages matching the search terms." },
{ "reply", notmuch_reply_command, FALSE,
"Construct a reply template for a set of messages." },
{ "tag", notmuch_tag_command, FALSE,
"Construct a reply template for a set of messages." },
{ "tag", notmuch_tag_command, FALSE,
"Add/remove tags for all messages matching the search terms." },
{ "dump", notmuch_dump_command, FALSE,
"Add/remove tags for all messages matching the search terms." },
{ "dump", notmuch_dump_command, FALSE,
"Create a plain-text dump of the tags for each message." },
{ "restore", notmuch_restore_command, FALSE,
"Create a plain-text dump of the tags for each message." },
{ "restore", notmuch_restore_command, FALSE,
{ "config", notmuch_config_command, FALSE,
{ "config", notmuch_config_command, FALSE,
"Get or set settings in the notmuch configuration file." },
{ "help", notmuch_help_command, TRUE, /* create but don't save config */
"Get or set settings in the notmuch configuration file." },
{ "help", notmuch_help_command, TRUE, /* create but don't save config */
upgrade your notmuch front-end.\n",
notmuch_format_version, NOTMUCH_FORMAT_MIN);
exit (NOTMUCH_EXIT_FORMAT_TOO_OLD);
upgrade your notmuch front-end.\n",
notmuch_format_version, NOTMUCH_FORMAT_MIN);
exit (NOTMUCH_EXIT_FORMAT_TOO_OLD);
/* Warn about old version requests so compatibility issues are
* less likely when we drop support for a deprecated format
* versions. */
/* Warn about old version requests so compatibility issues are
* less likely when we drop support for a deprecated format
* versions. */
"\tof difficulties check that MANPATH includes the pages\n"
"\tinstalled by notmuch.\n\n"
"\tTry \"notmuch help\" for a list of topics.\n");
"\tof difficulties check that MANPATH includes the pages\n"
"\tinstalled by notmuch.\n\n"
"\tTry \"notmuch help\" for a list of topics.\n");
if (errno != ENOENT) {
fprintf (stderr, "Error looking for notmuch database at %s: %s\n",
db_path, strerror (errno));
if (errno != ENOENT) {
fprintf (stderr, "Error looking for notmuch database at %s: %s\n",
db_path, strerror (errno));
"Note that the first run of \"notmuch new\" can take a very long time\n"
"and that the resulting database will use roughly the same amount of\n"
"storage space as the email being indexed.\n\n");
"Note that the first run of \"notmuch new\" can take a very long time\n"
"and that the resulting database will use roughly the same amount of\n"
"storage space as the email being indexed.\n\n");
notmuch_config_get_user_name (config),
notmuch_config_get_user_primary_email (config));
notmuch_config_get_user_name (config),
notmuch_config_get_user_primary_email (config));
notmuch_opt_desc_t options[] = {
{ NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 },
notmuch_opt_desc_t options[] = {
{ NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 },
/* Globally default to the current output format version. */
notmuch_format_version = NOTMUCH_FORMAT_CUR;
opt_index = parse_arguments (argc, argv, options, 1);
if (opt_index < 0) {
/* Globally default to the current output format version. */
notmuch_format_version = NOTMUCH_FORMAT_CUR;
opt_index = parse_arguments (argc, argv, options, 1);
if (opt_index < 0) {
talloc_report = getenv ("NOTMUCH_TALLOC_REPORT");
if (talloc_report && strcmp (talloc_report, "") != 0) {
talloc_report = getenv ("NOTMUCH_TALLOC_REPORT");
if (talloc_report && strcmp (talloc_report, "") != 0) {