[PATCH 1/5] CLI/show: accept --sort

Subject: [PATCH 1/5] CLI/show: accept --sort

Date: Sat, 26 Jun 2021 19:06:46 +0100

To: notmuch@notmuchmail.org

Cc: jao

From: jao


Add the command-line option --sort to the show command of the CLI
notmuch interface, with the same possible values as the same option in
notmuch search.
---
 notmuch-show.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/notmuch-show.c b/notmuch-show.c
index bdb87321..947ffa8d 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1244,8 +1244,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 },
@@ -1362,6 +1367,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);
-- 
2.32.0
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: