mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-27 21:27:58 +01:00
cli: update to use new count API
Essentially replace each call to notmuch_count_* with the corresponding _st call, followed by print_status_query.
This commit is contained in:
parent
87ee9a53e3
commit
e7b420a854
4 changed files with 36 additions and 6 deletions
|
@ -75,9 +75,11 @@ print_count (notmuch_database_t *notmuch, const char *query_str,
|
||||||
notmuch_query_t *query;
|
notmuch_query_t *query;
|
||||||
size_t i;
|
size_t i;
|
||||||
int count;
|
int count;
|
||||||
|
unsigned int ucount;
|
||||||
unsigned long revision;
|
unsigned long revision;
|
||||||
const char *uuid;
|
const char *uuid;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
notmuch_status_t status;
|
||||||
|
|
||||||
query = notmuch_query_create (notmuch, query_str);
|
query = notmuch_query_create (notmuch, query_str);
|
||||||
if (query == NULL) {
|
if (query == NULL) {
|
||||||
|
@ -90,10 +92,16 @@ print_count (notmuch_database_t *notmuch, const char *query_str,
|
||||||
|
|
||||||
switch (output) {
|
switch (output) {
|
||||||
case OUTPUT_MESSAGES:
|
case OUTPUT_MESSAGES:
|
||||||
printf ("%u", notmuch_query_count_messages (query));
|
status = notmuch_query_count_messages_st (query, &ucount);
|
||||||
|
if (print_status_query ("notmuch count", query, status))
|
||||||
|
return -1;
|
||||||
|
printf ("%u", ucount);
|
||||||
break;
|
break;
|
||||||
case OUTPUT_THREADS:
|
case OUTPUT_THREADS:
|
||||||
printf ("%u", notmuch_query_count_threads (query));
|
status = notmuch_query_count_threads_st (query, &ucount);
|
||||||
|
if (print_status_query ("notmuch count", query, status))
|
||||||
|
return -1;
|
||||||
|
printf ("%u", ucount);
|
||||||
break;
|
break;
|
||||||
case OUTPUT_FILES:
|
case OUTPUT_FILES:
|
||||||
count = count_files (query);
|
count = count_files (query);
|
||||||
|
|
|
@ -655,9 +655,14 @@ notmuch_reply_format_sprinter(void *ctx,
|
||||||
notmuch_messages_t *messages;
|
notmuch_messages_t *messages;
|
||||||
notmuch_message_t *message;
|
notmuch_message_t *message;
|
||||||
mime_node_t *node;
|
mime_node_t *node;
|
||||||
|
unsigned count;
|
||||||
notmuch_status_t status;
|
notmuch_status_t status;
|
||||||
|
|
||||||
if (notmuch_query_count_messages (query) != 1) {
|
status = notmuch_query_count_messages_st (query, &count);
|
||||||
|
if (print_status_query ("notmuch reply", query, status))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (count != 1) {
|
||||||
fprintf (stderr, "Error: search term did not match precisely one message.\n");
|
fprintf (stderr, "Error: search term did not match precisely one message.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,13 @@ do_search_threads (search_context_t *ctx)
|
||||||
notmuch_status_t status;
|
notmuch_status_t status;
|
||||||
|
|
||||||
if (ctx->offset < 0) {
|
if (ctx->offset < 0) {
|
||||||
ctx->offset += notmuch_query_count_threads (ctx->query);
|
unsigned count;
|
||||||
|
notmuch_status_t status;
|
||||||
|
status = notmuch_query_count_threads_st (ctx->query, &count);
|
||||||
|
if (print_status_query ("notmuch search", ctx->query, status))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
ctx->offset += count;
|
||||||
if (ctx->offset < 0)
|
if (ctx->offset < 0)
|
||||||
ctx->offset = 0;
|
ctx->offset = 0;
|
||||||
}
|
}
|
||||||
|
@ -521,7 +527,13 @@ do_search_messages (search_context_t *ctx)
|
||||||
notmuch_status_t status;
|
notmuch_status_t status;
|
||||||
|
|
||||||
if (ctx->offset < 0) {
|
if (ctx->offset < 0) {
|
||||||
ctx->offset += notmuch_query_count_messages (ctx->query);
|
unsigned count;
|
||||||
|
notmuch_status_t status;
|
||||||
|
status = notmuch_query_count_messages_st (ctx->query, &count);
|
||||||
|
if (print_status_query ("notmuch search", ctx->query, status))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
ctx->offset += count;
|
||||||
if (ctx->offset < 0)
|
if (ctx->offset < 0)
|
||||||
ctx->offset = 0;
|
ctx->offset = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -896,8 +896,13 @@ do_show_single (void *ctx,
|
||||||
notmuch_messages_t *messages;
|
notmuch_messages_t *messages;
|
||||||
notmuch_message_t *message;
|
notmuch_message_t *message;
|
||||||
notmuch_status_t status;
|
notmuch_status_t status;
|
||||||
|
unsigned int count;
|
||||||
|
|
||||||
if (notmuch_query_count_messages (query) != 1) {
|
status = notmuch_query_count_messages_st (query, &count);
|
||||||
|
if (print_status_query ("notmuch show", query, status))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (count != 1) {
|
||||||
fprintf (stderr, "Error: search term did not match precisely one message.\n");
|
fprintf (stderr, "Error: search term did not match precisely one message.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue