]> git.cworth.org Git - notmuch/blobdiff - notmuch-show.c
CLI/show: accept --sort
[notmuch] / notmuch-show.c
index 232557d5016f3ee3f555569de8107eb0da9a615d..c8f1a40f2e2803bfa93db1f5eb58132ddbd8b230 100644 (file)
@@ -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 },
@@ -1367,6 +1372,8 @@ notmuch_show_command (notmuch_database_t *notmuch, int argc, char *argv[])
        return EXIT_FAILURE;
     }
 
+    notmuch_query_set_sort (query, sort);
+
     /* Create structure printer. */
     formatter = formatters[format];
     sprinter = formatter->new_sprinter (notmuch, stdout);