+ if (print_help) {
+ int ret = _help_for (subcommand_name);
+ exit (ret);
+ }
+
+ if (notmuch) {
+ notmuch_exit_if_unmatched_db_uuid (notmuch);
+ } else {
+ if (notmuch_requested_db_uuid)
+ fprintf (stderr, "Warning: ignoring --uuid=%s\n",
+ notmuch_requested_db_uuid);
+ }
+}
+
+/* This is suitable for subcommands that do not actually open the
+ * database.
+ */
+int
+notmuch_minimal_options (const char *subcommand_name,
+ int argc, char **argv)
+{
+ int opt_index;
+
+ notmuch_opt_desc_t options[] = {
+ { .opt_inherit = notmuch_shared_options },
+ { }
+ };
+
+ opt_index = parse_arguments (argc, argv, options, 1);
+
+ if (opt_index < 0)
+ return -1;
+
+ /* We can't use argv here as it is sometimes NULL */
+ notmuch_process_shared_options (NULL, subcommand_name);
+ return opt_index;
+}
+
+
+struct _notmuch_client_indexing_cli_choices indexing_cli_choices = { };
+const notmuch_opt_desc_t notmuch_shared_indexing_options [] = {
+ { .opt_keyword = &indexing_cli_choices.decrypt_policy,
+ .present = &indexing_cli_choices.decrypt_policy_set, .keywords =
+ (notmuch_keyword_t []){ { "false", NOTMUCH_DECRYPT_FALSE },
+ { "true", NOTMUCH_DECRYPT_TRUE },
+ { "auto", NOTMUCH_DECRYPT_AUTO },
+ { "nostash", NOTMUCH_DECRYPT_NOSTASH },
+ { 0, 0 } },
+ .name = "decrypt" },
+ { }
+};
+
+
+notmuch_status_t
+notmuch_process_shared_indexing_options (notmuch_indexopts_t *opts)
+{
+ if (opts == NULL)
+ return NOTMUCH_STATUS_NULL_POINTER;
+
+ if (indexing_cli_choices.decrypt_policy_set) {
+ notmuch_status_t status;
+ status = notmuch_indexopts_set_decrypt_policy (opts,
+ indexing_cli_choices.decrypt_policy);
+ if (status != NOTMUCH_STATUS_SUCCESS) {
+ fprintf (stderr, "Error: Failed to set index decryption policy to %d. (%s)\n",
+ indexing_cli_choices.decrypt_policy, notmuch_status_to_string (status));
+ return status;
+ }
+ }
+ return NOTMUCH_STATUS_SUCCESS;
+}
+
+
+static const command_t commands[] = {
+ { NULL, notmuch_command, NOTMUCH_COMMAND_CONFIG_CREATE | NOTMUCH_COMMAND_CONFIG_LOAD,
+ "Notmuch main command." },
+ { "setup", notmuch_setup_command, NOTMUCH_COMMAND_CONFIG_CREATE | NOTMUCH_COMMAND_CONFIG_LOAD,
+ "Interactively set up notmuch for first use." },