[notmuch] [PATCH 1/2] notmuch search: Rename the --max-threads option to --max.

Carl Worth cworth at cworth.org
Sat Nov 21 08:24:18 PST 2009


The idea is to make this a little more general so that different
commands can use identical option names.
---
 notmuch-search.c |   22 +++++++++++-----------
 notmuch.c        |    2 +-
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index 2b1c0fe..845321d 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -29,7 +29,7 @@ static void
 do_search_threads (const void *ctx,
 		   notmuch_query_t *query,
 		   notmuch_sort_t sort,
-		   int first, int max_threads)
+		   int first, int max)
 {
     notmuch_thread_t *thread;
     notmuch_threads_t *threads;
@@ -37,7 +37,7 @@ do_search_threads (const void *ctx,
     time_t date;
     const char *relative_date;
 
-    for (threads = notmuch_query_search_threads (query, first, max_threads);
+    for (threads = notmuch_query_search_threads (query, first, max);
 	 notmuch_threads_has_more (threads);
 	 notmuch_threads_advance (threads))
     {
@@ -83,7 +83,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
     notmuch_database_t *notmuch;
     notmuch_query_t *query;
     char *query_str;
-    int i, first = 0, max_threads = -1;
+    int i, first = 0, max = -1;
     char *opt, *end;
     notmuch_sort_t sort = NOTMUCH_SORT_NEWEST_FIRST;
 
@@ -99,11 +99,11 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
 		fprintf (stderr, "Invalid value for --first: %s\n", opt);
 		return 1;
 	    }
-	} else if (STRNCMP_LITERAL (argv[i], "--max-threads=") == 0) {
-	    opt = argv[i] + sizeof ("--max-threads=") - 1;
-	    max_threads = strtoul (opt, &end, 10);
+	} else if (STRNCMP_LITERAL (argv[i], "--max=") == 0) {
+	    opt = argv[i] + sizeof ("--max=") - 1;
+	    max = strtoul (opt, &end, 10);
 	    if (*opt == '\0' || *end != '\0') {
-		fprintf (stderr, "Invalid value for --max-threads: %s\n", opt);
+		fprintf (stderr, "Invalid value for --max: %s\n", opt);
 		return 1;
 	    }
 	} else if (STRNCMP_LITERAL (argv[i], "--sort=") == 0) {
@@ -151,17 +151,17 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
 
     notmuch_query_set_sort (query, sort);
 
-    if (max_threads < 0 || max_threads > NOTMUCH_SHOW_INITIAL_BURST)
+    if (max < 0 || max > NOTMUCH_SHOW_INITIAL_BURST)
     {
 	do_search_threads (ctx, query, sort,
 			   first, NOTMUCH_SHOW_INITIAL_BURST);
 
 	first += NOTMUCH_SHOW_INITIAL_BURST;
-	if (max_threads > 0)
-	    max_threads -= NOTMUCH_SHOW_INITIAL_BURST;
+	if (max > 0)
+	    max -= NOTMUCH_SHOW_INITIAL_BURST;
     }
 
-    do_search_threads (ctx, query, sort, first, max_threads);
+    do_search_threads (ctx, query, sort, first, max);
 
     notmuch_query_destroy (query);
     notmuch_database_close (notmuch);
diff --git a/notmuch.c b/notmuch.c
index 5cc8e4c..14d4865 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -139,7 +139,7 @@ command_t commands[] = {
       "\n"
       "\t\tSupported options for search include:\n"
       "\n"
-      "\t\t--max-threads=<value>\n"
+      "\t\t--max=<value>\n"
       "\n"
       "\t\t\tRestricts displayed search results to a subset\n"
       "\t\t\tof the results that would match the terms.\n"
-- 
1.6.5.2



More information about the notmuch mailing list