+ return 0;
+}
+
+int
+notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])
+{
+ notmuch_database_t *notmuch;
+ notmuch_query_t *query;
+ char *query_string;
+ int opt_index;
+ notmuch_show_params_t params = {
+ .part = -1,
+ .crypto = { .decrypt = NOTMUCH_DECRYPT_AUTO },
+ };
+ int format = FORMAT_DEFAULT;
+ int reply_all = true;
+ bool decrypt = false;
+ bool decrypt_set = false;
+
+ notmuch_opt_desc_t options[] = {
+ { .opt_keyword = &format, .name = "format", .keywords =
+ (notmuch_keyword_t []){ { "default", FORMAT_DEFAULT },
+ { "json", FORMAT_JSON },
+ { "sexp", FORMAT_SEXP },
+ { "headers-only", FORMAT_HEADERS_ONLY },
+ { 0, 0 } } },
+ { .opt_int = ¬much_format_version, .name = "format-version" },
+ { .opt_keyword = &reply_all, .name = "reply-to", .keywords =
+ (notmuch_keyword_t []){ { "all", true },
+ { "sender", false },
+ { 0, 0 } } },
+ { .opt_bool = &decrypt, .name = "decrypt", .present = &decrypt_set },
+ { .opt_inherit = notmuch_shared_options },
+ { }
+ };
+
+ opt_index = parse_arguments (argc, argv, options, 1);
+ if (opt_index < 0)
+ return EXIT_FAILURE;
+
+ notmuch_process_shared_options (argv[0]);
+ if (decrypt_set)
+ params.crypto.decrypt = decrypt ? NOTMUCH_DECRYPT_NOSTASH : NOTMUCH_DECRYPT_FALSE;
+
+ notmuch_exit_if_unsupported_format ();
+
+ query_string = query_string_from_args (config, argc-opt_index, argv+opt_index);
+ if (query_string == NULL) {
+ fprintf (stderr, "Out of memory\n");
+ return EXIT_FAILURE;
+ }
+
+ if (*query_string == '\0') {
+ fprintf (stderr, "Error: notmuch reply requires at least one search term.\n");
+ return EXIT_FAILURE;
+ }
+
+#if (GMIME_MAJOR_VERSION < 3)
+ params.crypto.gpgpath = notmuch_config_get_crypto_gpg_path (config);
+#endif
+
+ if (notmuch_database_open (notmuch_config_get_database_path (config),
+ NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much))
+ return EXIT_FAILURE;
+
+ notmuch_exit_if_unmatched_db_uuid (notmuch);
+
+ query = notmuch_query_create (notmuch, query_string);
+ if (query == NULL) {
+ fprintf (stderr, "Out of memory\n");
+ return EXIT_FAILURE;
+ }
+
+ if (do_reply (config, query, ¶ms, format, reply_all) != 0)
+ return EXIT_FAILURE;
+
+ _notmuch_crypto_cleanup (¶ms.crypto);