Commit graph

28 commits

Author SHA1 Message Date
David Bremner
81bd41c7cb cli/count: simplify and document return value of print_count
Essentially a cosmetic change.
2015-10-05 19:39:53 -03:00
David Bremner
dca72205ab cli/count: update to use notmuch_query_search_messages_st
This brings back status information that may have been hidden by the
great library logging conversion.

Note the change of the internal API / return-value for count_files. The
other count calls to the lib will also get error handling when that API
is updated in the lib.
2015-09-20 08:04:51 -03:00
David Bremner
d4321162ae cli/count: apply uncrustify changes
Leave the indentation alone because I don't know how to duplicate it
with Emacs.
2015-09-09 20:16:24 -03:00
David Bremner
8c2f9bdfbb cli/count: remove unused argument handling for output=modifications
In the end this UI was rejected, but bits of it stayed in the code to
confuse future generations.
2015-09-07 10:08:25 -03:00
David Bremner
f76d8f82dd cli: add global option "--uuid"
The function notmuch_exit_if_unmatched_db_uuid is split from
notmuch_process_shared_options because it needs an open notmuch
database.

There are two exceptional cases in uuid handling.

1) notmuch config and notmuch setup don't currently open the database,
   so it doesn't make sense to check the UUID.

2) notmuch compact opens the database inside the library, so we either
   need to open the database just to check uuid, or change the API.
2015-08-14 18:23:49 +02:00
David Bremner
5a3b42fb8c cli/count: add --lastmod
In the short term we need a way to get lastmod information e.g. for
the test suite. In the long term we probably want to add lastmod
information to at least the structured output for several other
clients (e.g. show, search).
2015-08-14 18:07:55 +02:00
David Bremner
0018a8d787 cli: define shared options, use for --help and --version
Unfortunately it seems trickier to support --config globally

The non-trivial changes are in notmuch.c; most of the other changes
consists of blindly inserting two lines into every subcommand.
2015-06-01 07:32:54 +02:00
Jani Nikula
c745377306 cli: clean up exit status code returned by the cli commands
Apart from the status codes for format mismatches, the non-zero exit
status codes have been arbitrary. Make the cli consistently return
either EXIT_SUCCESS or EXIT_FAILURE.
2014-01-18 14:45:26 -04:00
Jani Nikula
431571242c cli: add --output=files option to notmuch count
Add support for querying the total number of files associated with the
messages matching the search. This is mostly useful with an
id:<message-id> query for a single message.
2013-08-24 11:42:39 +02:00
Jani Nikula
c6265706e8 cli: add --batch option to notmuch count
Add support for reading queries from stdin, one per line, and writing
results to stdout, one per line.

This will bring considerable performance improvements when utilized in
Emacs notmuch-hello, especially so when running remote notmuch.
2013-04-01 09:36:09 -04:00
Jani Nikula
530b562111 cli: extract count printing to a separate function in notmuch count
Make count printing on a query string reusable. No functional changes.
2013-04-01 09:35:52 -04:00
Jani Nikula
ab65c365d5 cli: remove useless talloc_strdup
If the condition holds, query_string_from_args() has already returned
a talloc allocated empty string. There's no need to duplicate that.
2013-04-01 09:34:44 -04:00
Jani Nikula
4ef2106792 cli: move config open/close to main() from subcommands
This allows specifying config file as a top level argument to notmuch,
and generally makes it possible to override config file options in
main(), without having to touch the subcommands.

If the config file does not exist, one will be created for the notmuch
main command and setup and help subcommands. Help is special in this
regard; the config is created just to avoid errors about missing
config, but it will not be saved.

This also makes notmuch config the talloc context for subcommands.
2013-03-08 07:54:41 -04:00
Jani Nikula
e76f6517de cli: config: make notmuch_config_open() "is new" parameter input only
We now have a notmuch_config_is_new() function to query whether a
config was created or not. Change the notmuch_config_open() is_new
parameter into boolean create_new to determine whether the function
should create a new config if one doesn't exist. This reduces the
complexity of the API.
2013-03-07 09:39:12 -04:00
Austin Clements
5fddc07dc3 lib/cli: Make notmuch_database_open return a status code
It has been a long-standing issue that notmuch_database_open doesn't
return any indication of why it failed.  This patch changes its
prototype to return a notmuch_status_t and set an out-argument to the
database itself, like other functions that return both a status and an
object.

In the interest of atomicity, this also updates every use in the CLI
so that notmuch still compiles.  Since this patch does not update the
bindings, the Python bindings test fails.
2012-05-05 10:11:57 -03:00
Justus Winter
6f7469f547 Use notmuch_database_destroy instead of notmuch_database_close
Adapt the notmuch binaries source to the notmuch_database_close split.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-04-28 09:27:33 -03:00
Mark Walters
785c1e497f cli: move count to the new --exclude=(true|false|flag) naming scheme.
Move the option --no-exclude to the --exclude= scheme. Since there is
no way to flag messages only true and false are implemented. Note
that, for consistency with other commands, this is implemented as a
keyword option rather than a boolean option.
2012-04-07 23:05:18 -03:00
Mark Walters
7a1beb9e7c cli: omit excluded messages in results where appropriate.
In all cases of notmuch count/search/show where the results returned
cannot reflect the exclude flag return just the matched not-excluded
results. If the caller wishes to have all the matched results (i.e.,
including the excluded ones) they should call with the
--no-exclude option.

The relevant cases are
    count: both threads and messages
    search: all cases except the summary view
    show: mbox format
2012-03-02 08:37:32 -04:00
Mark Walters
d845662970 cli: add --no-exclude option to count and search.
This option turns off the exclusion so all matching messages are
returned. We do not need to add this to notmuch-show as that does not
(yet) exclude.
2012-03-02 08:24:38 -04:00
Pieter Praet
649a9f5f3a search: rename auto_exclude_tags to {search, }exclude_tags
All other config-related functions and args include the section
title in their name, so for the sake of consistency, mirror that.

Also, the "auto"matic part is a given, so that was dropped.
2012-01-23 19:17:16 -04:00
Austin Clements
42a9079928 search: Support automatic tag exclusions
This adds a "search" section to the config file and an
"auto_tag_exclusions" setting in that section.  The search and count
commands pass tag tags from the configuration to the library.
2012-01-16 21:06:35 -04:00
Austin Clements
e40c01bb14 count: Convert to new-style argument parsing 2012-01-13 21:43:54 -04:00
Jani Nikula
386ad3d6a1 cli: add support for --output parameter in notmuch count
Add support for --output=messages (which remains the default) and
--output=threads to notmuch count.

Signed-off-by: Jani Nikula <jani@nikula.org>
2011-11-15 19:20:27 -04:00
Jani Nikula
e7328d7b00 cli: drop unused code from notmuch count
Remove unused code within #if 0 blocks from notmuch count.

Signed-off-by: Jani Nikula <jani@nikula.org>
2011-11-15 19:19:28 -04:00
David Bremner
61f0a5b8ee cli: change argument parsing convention for subcommands
previously we deleted the subcommand name from argv before passing to
the subcommand. In this version, the deletion is done in the actual
subcommands. Although this causes some duplication of code, it allows
us to be more flexible about how we parse command line arguments in
the subcommand, including possibly using off-the-shelf routines like
getopt_long that expect the name of the command in argv[0].
2011-10-22 19:42:54 -03:00
Carl Worth
13a7b6700e notmuch count: Remove special handling of "*".
From both the implementation and from the documentation. This is
handled generically in the library for all search-based commands,
so count doesn't need special treatment.
2010-04-09 17:44:01 -07:00
Mike Kelly
b15a03fafc Have notmuch count default to showing the total.
If no parameters are given to notmuch-count, or just '' or '*' are
given, return the total number of messages in the database.

update notmuch count help
2010-04-09 16:28:49 -07:00
Keith Packard
53f8cc5651 Add 'notmuch count' command to show the count of matching messages
Getting the count of matching threads or messages is a fairly
expensive operation. Xapian provides a very efficient mechanism that
returns an approximate value, so use that for this new command.

This returns the number of matching messages, not threads, as that is
cheap to compute.

Signed-off-by: Keith Packard <keithp@keithp.com>
2009-11-23 06:33:54 +01:00