mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-04 16:38:14 +01:00
CLI/show: complete conversion to new configuration framework.
In order to open the database in main() for this command, we may need to re-open it in the (possibly less common) case where crypto options require write access.
This commit is contained in:
parent
a9f74aeeb9
commit
6e6c319c26
3 changed files with 9 additions and 23 deletions
|
@ -1225,10 +1225,9 @@ static const notmuch_show_format_t *formatters[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch),
|
notmuch_show_command (unused (notmuch_config_t *config), notmuch_database_t *notmuch,
|
||||||
int argc, char *argv[])
|
int argc, char *argv[])
|
||||||
{
|
{
|
||||||
notmuch_database_t *notmuch;
|
|
||||||
notmuch_query_t *query;
|
notmuch_query_t *query;
|
||||||
char *query_string;
|
char *query_string;
|
||||||
int opt_index, ret;
|
int opt_index, ret;
|
||||||
|
@ -1245,7 +1244,7 @@ notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t *notmu
|
||||||
bool entire_thread_set = false;
|
bool entire_thread_set = false;
|
||||||
bool single_message;
|
bool single_message;
|
||||||
bool unthreaded = FALSE;
|
bool unthreaded = FALSE;
|
||||||
char *status_string = NULL;
|
notmuch_status_t status;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ .opt_keyword = &format, .name = "format", .keywords =
|
{ .opt_keyword = &format, .name = "format", .keywords =
|
||||||
|
@ -1336,25 +1335,14 @@ notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t *notmu
|
||||||
"Warning: --include-html only implemented for format=text, format=json and format=sexp\n");
|
"Warning: --include-html only implemented for format=text, format=json and format=sexp\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
notmuch_database_mode_t mode = NOTMUCH_DATABASE_MODE_READ_ONLY;
|
if (params.crypto.decrypt == NOTMUCH_DECRYPT_TRUE) {
|
||||||
|
status = notmuch_database_reopen (notmuch, NOTMUCH_DATABASE_MODE_READ_WRITE);
|
||||||
if (params.crypto.decrypt == NOTMUCH_DECRYPT_TRUE)
|
if (status) {
|
||||||
mode = NOTMUCH_DATABASE_MODE_READ_WRITE;
|
fprintf (stderr, "Error reopening database for READ_WRITE: %s\n",
|
||||||
if (notmuch_database_open_with_config (NULL,
|
notmuch_status_to_string (status));
|
||||||
mode,
|
|
||||||
_notmuch_config_get_path (config),
|
|
||||||
NULL,
|
|
||||||
¬much,
|
|
||||||
&status_string)) {
|
|
||||||
if (status_string) {
|
|
||||||
fputs (status_string, stderr);
|
|
||||||
free (status_string);
|
|
||||||
}
|
|
||||||
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
config = NULL;
|
|
||||||
|
|
||||||
notmuch_exit_if_unmatched_db_uuid (notmuch);
|
notmuch_exit_if_unmatched_db_uuid (notmuch);
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ static command_t commands[] = {
|
||||||
"Search for messages matching the given search terms." },
|
"Search for messages matching the given search terms." },
|
||||||
{ "address", notmuch_address_command, NOTMUCH_COMMAND_DATABASE_EARLY,
|
{ "address", notmuch_address_command, NOTMUCH_COMMAND_DATABASE_EARLY,
|
||||||
"Get addresses from messages matching the given search terms." },
|
"Get addresses from messages matching the given search terms." },
|
||||||
{ "show", notmuch_show_command, NOTMUCH_COMMAND_CONFIG_OPEN,
|
{ "show", notmuch_show_command, NOTMUCH_COMMAND_DATABASE_EARLY,
|
||||||
"Show all messages matching the search terms." },
|
"Show all messages matching the search terms." },
|
||||||
{ "count", notmuch_count_command, NOTMUCH_COMMAND_DATABASE_EARLY,
|
{ "count", notmuch_count_command, NOTMUCH_COMMAND_DATABASE_EARLY,
|
||||||
"Count messages matching the search terms." },
|
"Count messages matching the search terms." },
|
||||||
|
|
|
@ -378,7 +378,6 @@ restore_database
|
||||||
test_expect_equal "$output" "OK"
|
test_expect_equal "$output" "OK"
|
||||||
|
|
||||||
test_begin_subtest "show with alternate config (xdg)"
|
test_begin_subtest "show with alternate config (xdg)"
|
||||||
test_subtest_known_broken
|
|
||||||
backup_database
|
backup_database
|
||||||
notmuch tag -- +foobar17 '*'
|
notmuch tag -- +foobar17 '*'
|
||||||
xdg_config
|
xdg_config
|
||||||
|
@ -389,7 +388,6 @@ restore_config
|
||||||
test_expect_equal "$output" "OK"
|
test_expect_equal "$output" "OK"
|
||||||
|
|
||||||
test_begin_subtest "show with alternate config (xdg+profile)"
|
test_begin_subtest "show with alternate config (xdg+profile)"
|
||||||
test_subtest_known_broken
|
|
||||||
backup_database
|
backup_database
|
||||||
notmuch tag -- +foobar17 '*'
|
notmuch tag -- +foobar17 '*'
|
||||||
xdg_config foobar17
|
xdg_config foobar17
|
||||||
|
|
Loading…
Reference in a new issue