X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-show.c;h=2848c9c39372fcbad778231c625632119b8e4faa;hp=232557d5016f3ee3f555569de8107eb0da9a615d;hb=4f4ec48df25c8d2963e7124d2781b13e5a7f6a78;hpb=8c29a5da096b0314c6cca8889b740b79a9a548ed diff --git a/notmuch-show.c b/notmuch-show.c index 232557d5..2848c9c3 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -1249,8 +1249,13 @@ notmuch_show_command (notmuch_database_t *notmuch, int argc, char *argv[]) bool single_message; bool unthreaded = FALSE; notmuch_status_t status; + int sort = NOTMUCH_SORT_NEWEST_FIRST; notmuch_opt_desc_t options[] = { + { .opt_keyword = &sort, .name = "sort", .keywords = + (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST }, + { "newest-first", NOTMUCH_SORT_NEWEST_FIRST }, + { 0, 0 } } }, { .opt_keyword = &format, .name = "format", .keywords = (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON }, { "text", NOTMUCH_FORMAT_TEXT }, @@ -1282,7 +1287,7 @@ notmuch_show_command (notmuch_database_t *notmuch, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; - notmuch_process_shared_options (argv[0]); + notmuch_process_shared_options (notmuch, argv[0]); /* explicit decryption implies verification */ if (params.crypto.decrypt == NOTMUCH_DECRYPT_NOSTASH || @@ -1348,8 +1353,6 @@ notmuch_show_command (notmuch_database_t *notmuch, int argc, char *argv[]) } } - notmuch_exit_if_unmatched_db_uuid (notmuch); - query_string = query_string_from_args (notmuch, argc - opt_index, argv + opt_index); if (query_string == NULL) { fprintf (stderr, "Out of memory\n"); @@ -1361,11 +1364,13 @@ notmuch_show_command (notmuch_database_t *notmuch, int argc, char *argv[]) return EXIT_FAILURE; } - query = notmuch_query_create (notmuch, query_string); - if (query == NULL) { - fprintf (stderr, "Out of memory\n"); + status = notmuch_query_create_with_syntax (notmuch, query_string, + shared_option_query_syntax (), + &query); + if (print_status_database ("notmuch show", notmuch, status)) return EXIT_FAILURE; - } + + notmuch_query_set_sort (query, sort); /* Create structure printer. */ formatter = formatters[format];