Commit graph

155 commits

Author SHA1 Message Date
David Bremner
3380498042 CLI: add talloc leak report, controlled by an environment variable.
The argument handling in notmuch.c seems due for an overhaul, but
until then use an environment variable to specify a location to write
the talloc leak report to.  This is only enabled for the (interesting)
case where some notmuch subcommand is invoked.
2012-12-30 21:12:03 -04:00
Austin Clements
1c6195b9e3 cli: Framework for structured output versioning
Currently there is a period of pain whenever we make
backward-incompatible changes to the structured output format, which
discourages not only backward-incompatible improvements to the format,
but also backwards-compatible additions that may not be "perfect".  In
the end, these problems limit experimentation and innovation.

This series of patches introduces a way for CLI callers to request a
specific format version on the command line and to determine if the
CLI does not supported the requested version (and perhaps present a
useful diagnostic to the user).  Since the caller requests a format
version, it's also possible for the CLI to support multiple
incompatible versions simultaneously, unlike the alternate approach of
including version information in the output.

This patch lays the groundwork by introducing a versioning convention,
standard exit codes, and a utility function to check the requested
version and produce standardized diagnostic messages and exit
statuses.
2012-12-16 17:20:33 -04:00
Jani Nikula
8ce50f300f cli: fix notmuch top level argument parsing
Use strcmp instead of STRNCMP_LITERAL, which matches the prefix
instead of the whole argument.
2012-12-04 09:10:19 -04:00
David Bremner
07768fb1bb notmuch: replace built-in help with exec of man
"notmuch help" now relies on a working man installation, and a correct
setting of MANPATH, for users that install in "unusual" places. This
should probably noted in NEWS before shipping.

There is still some small duplication of docs as the one line
summaries are hard coded in the binary. This seems preferable to
complicated script games, at least as long was we are using a
presentation level markup like nroff.
2011-12-31 15:16:32 -04:00
Jani Nikula
69bb7f35b6 cli: add support for pre and post notmuch new hooks
Run notmuch new pre and post hooks, named "pre-new" and "post-new", if
present in the notmuch hooks directory. The hooks will be run before and
after incorporating new messages to the database.

Typical use cases for pre-new and post-new hooks are fetching or delivering
new mail to the maildir, and custom tagging of the mail incorporated to the
database.

Also add command line option --no-hooks to notmuch new to bypass the hooks.

Signed-off-by: Jani Nikula <jani@nikula.org>
2011-12-11 13:58:15 -04:00
David Bremner
879c2a57a0 CLI: update call to notmuch_help_command for new calling conventions.
When I changed the calling convention to pass in all but the zero-th
argument to subcommands, I missed this one call, resulting in a
segmentation fault.

As a bonus, the syntax "notmuch --help foo" is now equivalent to
"notmuch help foo".
2011-11-25 12:07:10 -05: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
796b629c3b cli: add options --offset and --limit to notmuch search
Add options --offset=[-]N and --limit=M to notmuch search to determine the
first result and maximum number of results to display.

Option --limit=M limits the maximum number of results to display to M.

Option --offset=[-]N skips the first N results; with the leading '-' skip
until the Nth result from the end.

Note that --offset with a negative N for thread or summary output requires
counting the number of matching threads in advance.

Signed-off-by: Jani Nikula <jani@nikula.org>
2011-11-15 19:17:24 -04:00
David Bremner
3ae8ac6ace docs: Update news, man page, and online help for restore --accumulate
As a side effect, reformat the NEWs entry for notmuch dump for
consistency with the notmuch restore NEWS submitted by Thomas
Schwinge.
2011-10-23 10:27:57 -03: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
David Bremner
8bb5b6201e docs: Update man page, NEWS and online help for new dump arguments.
We mention in all three places that using the filename argument is
deprecated.
2011-10-16 20:10:03 -03:00
Aaron Ecay
fa52a0d094 Add missing call to g_type_init()
The Glib docs state "Prior to any use of the type system, g_type_init() has to
be called".[1] To not do so can lead to segfaults.  The g_type system is
currently used by various "filters" that operate on uuencoded text, message
headers, etc.

[1] http://developer.gnome.org/gobject/2.28/gobject-Type-Information.html#g-type-init
2011-09-10 15:19:51 -03:00
Pieter Praet
432e091924 fix sum moar typos [user-visible documentation in code]
Various typo fixes in documentation within the code that can be made
available to the user, (emacs function help strings, "notmuch help"
output, notmuch man page, etc.).

Signed-off-by: Pieter Praet <pieter@praet.org>

Edited-by: Carl Worth <cworth@cworth.org> Restricted to just
documentation and fixed fix of "comman" to "common" rather than
"command".
2011-06-23 15:58:50 -07:00
Jameson Graef Rollins
2e653db38f Add decryption of PGP/MIME-encrypted parts with --decrypt.
This adds support for decrypting PGP/MIME-encrypted parts to
notmuch-show and notmuch-reply.  The --decrypt option implies
--verify.  Once decryption (and possibly signature verification) is
done, a new part_encstatus formatter is emitted, the part_sigstatus
formatter is emitted, and the entire multipart/encrypted part is
replaced by the contents of the encrypted part.

At the moment only a json part_encstatus formatting function is
available, even though decryption is done for all formats.  Emacs
support to follow.
2011-05-27 16:22:00 -07:00
Jameson Graef Rollins
8b18efe171 Add signature verification of PGP/MIME-signed parts with --verify.
This is primarily for notmuch-show, although the functionality is
added to show-message.  Once signatures are processed a new
part_sigstatus formatter is emitted, and the entire multipart/signed
part is replaced with the contents of the signed part.

At the moment only a json part_sigstatus formatting function is
available.  Emacs support to follow.

The original work for this patch was done by

  Daniel Kahn Gillmor <dkg@fifthhorseman.net>

whose help with this functionality I greatly appreciate.
2011-05-27 16:22:00 -07:00
Carl Worth
4f926e140f notmuch: Implement search-tags as an alias for "search --output=tags *"
Ever since we added support for "notmuch search --output=tags" the
"notmuch search-tags" command has been redundant. The recent addition
of alias support makes it easy to drop the explicit search-tags
command in favor of a simple alias that runs "notmuch search
--output=tags *".

So there's no longer any documentation of the search-tags command, but
existing scripts will not break at all.
2011-05-24 12:19:18 -07:00
Carl Worth
a06889c8d4 notmuch show: Update documentation for default --format=raw for --part
We recently made the --part option to "notmuch show" trigger a default
format of "raw", (since the previous default of "text" is not often
useful with a single part---especially a non-text part).

Here, we update the documentation to match.
2011-05-24 12:19:18 -07:00
Carl Worth
150db11214 notmuch: Support "notmuch part" as an alias for "notmuch show --format=raw"
We unifed the "notmuch part" functionality into "notmuch show" where
the implementation is both simpler and more powerful. But there's no
good reason to break users of the old interface.

Add support for aliases, which are undocumented means of getting at
functionality through deprecated names. The first such alias is
"notmuch part" as implemented here.
2011-05-24 12:04:08 -07:00
Jameson Graef Rollins
2f8871df6e New part output handling as option to notmuch-show.
Outputting of single MIME parts is moved to an option of notmuch show,
instead of being handled in it's own sub-command.  The recent rework
of multipart mime allowed for this change but consolidating part
handling into a single recursive function (show_message_part) that
includes formatting.  This allows for far simpler handling single
output of a single part, including formatting.
2011-05-23 15:31:32 -07:00
Carl Worth
362ab047c2 notmuch show: Properly nest MIME parts within mulipart parts
Previously, notmuch show flattened all output, losing information
about the nesting of the MIME hierarchy. Now, the output is properly
nested, (both in the --format=text and --format=json output), so that
clients can analyze the original MIME structure.

Internally, this required splitting the final closing delimiter out of
the various show_part functions and putting it into a new
show_part_end function instead. Also, the show_part function now
accepts a new "first" argument that is set not only for the first MIME
part of a message, but also for each first MIME part within a series
of multipart parts. This "first" argument controls the omission of a
preceding comma when printing a part (for json).

Many thanks to David Edmondson <dme@dme.org> for originally
identifying the lack of nesting in the json output and submitting an
early implementation of this feature. Thanks as well to Jameson Graef
Rollins <jrollins@finestructure.net> for carefully shepherding David's
patches through a remarkably long review process, patiently explaining
them, and providing a cleaned up series that led to this final
implementation. Jameson also provided the new emacs code here.
2011-05-17 15:58:57 -07:00
Carl Worth
b64afb1ab9 notmuch search: Clean up some memory leaks during search loop.
With talloc, we were already freeing all memory by the time we exited
the loop, but that didn't help with excess use of memory inside the
loop, (which was mostly from tallocing some objects with the incorrect
parent).

Thanks to Andrew Tridgell for sitting next to me and teaching me to
use talloc_report_full to find these leaks.
2011-01-26 15:59:19 +10:00
Carl Worth
3863e88e96 Add documentation for the recently added folder-based searching.
Augmenting both the builtin help as well as the manual page.
2011-01-15 15:37:43 -08:00
Carl Worth
81d3bd3670 Rename "notmuch cat" to "notmuch show --format=raw"
This is part of an effort to avoid proliferation of excessive
top-level notmuch commands. Also, "raw" better captures the
functionality here, (as opposed to "cat" which is a fairly oblique
reference to a bad Unix abbreviation whose metaphor doesn't work here
since "notmuch cat" operates only on a single message and hence cannot
"con'cat'enate" anything).
2010-11-06 12:03:51 -07:00
Michal Sojka
d39d0e55f0 Add 'cat' subcommand
This command outputs a raw message matched by search term to the
standard output. It allows MUAs to access the messages for piping,
attachment manipulation, etc. by running notmuch cat rather then
directly access the file. This will simplify the MUAs when they need
to operate on a remote database.

Edited-by: Carl Worth <cworth@cworth.org>: Remove trailing whitespace,
add missing "test_done" to new test script to avoid "Unexpected exit"
error.
2010-11-05 17:51:18 -07:00
Carl Worth
ce6390cee7 documentation: Add the "files" option to the synopsis of "search --output="
This was inadvertently left off when --output=files was recently added
as a new option.
2010-10-28 12:15:51 -07:00
Carl Worth
5331161749 notmuch search: Add a new "notmuch search --output=files"
Yet another thing that will be extremely handy for scripts.
2010-10-28 11:35:54 -07:00
Carl Worth
6dcb7592e3 notmuch search: Add a new --output=(summary|threads|messages|tags) option.
This can be handy for scripts which need to extract just a thread ID from
a search term, for example.
2010-10-28 11:35:16 -07:00
Carl Worth
65f2e61f28 notmuch config: Allow for new "notmuch config set" in addition to get
It is now possible to set configuration items from the command-line in
a manner quite similar to the support for querying configuration
items.
2010-10-27 15:38:16 -07:00
Carl Worth
b9eac48c22 notmuch: Add a new "notmuch config" command for querying configuration.
So far, we implement only "notmuch config get". It won't be too much
work from here to also implement "notmuch config set".
2010-10-27 13:02:17 -07:00
Carl Worth
9f0accb6aa notmuch show: Add documentation of --format=mbox
Shame on me for adding a feature without documenting it at the same
time.
2010-09-16 14:47:32 -07:00
Jameson Rollins
419b88059d Fix help message for "show"
Help message for "show" mistakenly refers to '--output' instead of
'--format'.
2010-04-21 17:45:39 -07:00
Sebastian Spaeth
43cbbfc278 notmuch.c: Shorten version string
We previously output "notmuch version 0.1" as response to notmuch --version.
Shorten this to "notmuch 0.1" as we know that we will receive a version
number when we explicitely ask for it.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2010-04-16 07:35:17 -07:00
Carl Worth
d55d31d342 notmuch count: Remove unneeded paragraph from documentation.
This paragraph acts like it's introducing an example, but then no
example is given. Just drop this.
2010-04-09 17:44:01 -07: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
Carl Worth
74168777cb notmuch: Document the new special-case syntax of "*".
This functionality came through a recent addition to the library.
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
Carl Worth
44df403ccd Merge remote branch 'dme/dme-for-cworth'
Conflicts:
	notmuch.c (Simply the change in documentation indentation level).
2010-04-02 15:47:27 -07:00
Carl Worth
3d33ec7349 notmuch help: Eliminate a gratuitous level of indentation.
I don't really know why we ended up having everything indented by two
tabs, (perhaps trying to make it match the man page)? But wihout any
containing context to justify that it just looks odd.
2010-04-02 12:26:31 -07:00
Carl Worth
5a9be8a7ad notmuch help: Simplify output by omitting arguments for each command.
The output was far too busy otherwise. It's more useful to just
show the argument list in the case of "notmuch help <command>"
for a specific command.

(Credit due to running "git help" and seeing a much more readable
list than what was coming out of "notmuch help".)
2010-04-02 12:12:18 -07:00
Carl Worth
b2a9fcd5cf notmuch: Add a version (0.1 initially) with a new --version option.
We're planning to do actual releases soon, so we need a version
number to put into the tar file.
2010-04-02 11:55:09 -07:00
Carl Worth
9d9aeb7c71 notmuch: Add support for a --help option.
Previously, only "notmuch help" worked while a call to "notmuch --help"
would just print a message telling the user to call "notmuch help".
Instead of the redirection, just support --help directly now.
2010-04-02 11:53:22 -07:00
David Edmondson
2e9c7aba99 notmuch: Add a 'part' subcommand
A new 'part' subcommand allows the user to extract a single part from
a MIME message. Usage:
  notmuch part --part=<n> <search terms>
The search terms must match only a single message
(e.g. id:foo@bar.com). The part number specified refers to the part
identifiers output by `notmuch show'. The content of the part is
written the stdout with no formatting or identification marks. It is
not JSON formatted.
2010-04-02 09:43:03 +01:00
Carl Worth
e3046c688b Add is:<tag> as a synonym for tag:<tag> in search terms.
I like the readability of this, it provides compatibility with people
trained in this syntax by sup, and it even saves one character.
2010-03-09 16:03:58 -08:00
Scott Robinson
6ce2bf68f5 Add an "--format=(json|text)" command-line option to both notmuch-search and notmuch-show.
In the case of notmuch-show, "--format=json" also implies
"--entire-thread" as the thread structure is implicit in the emitted
document tree.

As a coincidence to the implementation, multipart message ID numbers are
now incremented with each part printed. This changes the previous
semantics, which were unclear and not necessary related to the actual
ordering of the message parts.
2010-02-23 12:01:12 -08:00
Carl Worth
3a9c3ec9e7 notmuch new: Remove hack to ignore read-only directories in mail store.
This was really the last thing keeping the initial run of "notmuch
new" being different from all other runs. And I'm taking a fresh
look at the performance of "notmuch new" anyway, so I think we can
safely drop this optimization.
2010-01-06 10:32:05 -08:00
Carl Worth
63c503a5ac notmuch.1: Document the new --entire-thread option to "notmuch show".
This was added to "notmuch help" earlier, but not to the man page.
Add it there, and use consistent wording in both places.
2009-12-02 16:14:41 -08:00
Bart Trojanowski
d50c67d53b notmuch show: limit display to only matching messages
This patch changes the default behaviour of notmuch show to display only
messages that match the search expression.  However, --entire-thread
option is provided to display all messages in threads that matched the
search expression.

It is deemed that will be more useful for human users on the command line.
Scripts can be modified to include the --entire-thread option so that they
can display all messages once more.

Example:

$ notmuch search subject:git AND thread:23d99d0f364f93e90e15df8b42eddb5b
thread:23d99d0f364f93e90e15df8b42eddb5b      July 31 [4/12] Johan Herland; [RFCv2 00/12] Foreign VCS helper program for CVS repositories (inbox unread)

Note that in this thread 4 out of 12 messages matched.  The default show
behaviour is to show only those messages that match:

$ notmuch show subject:git AND thread:23d99d0f364f93e90e15df8b42eddb5b | grep 'message{' | wc -l
4

With the --entire-thread option the output will contain all dozen
messages:

$ notmuch show --entire-thread subject:git AND thread:23d99d0f364f93e90e15df8b42eddb5b | grep 'message{' | wc -l
12

Signed-off-by: Bart Trojanowski <bart@jukie.net>
2009-12-02 14:32:14 -08:00
Jed Brown
a2a522a758 Documentation for notmuch reply --format=(default|headers-only)
Signed-off-by: Jed Brown <jed@59A2.org>
2009-11-28 12:13:02 -08:00
Jan Janak
5a447b00ac search-tags: Add support for search-terms.
This patch adds support for search-terms to 'notmuch search-tags'. If
no search-term is provided then the command returns a list of all tags
from the database.

If the user provides one or more search-terms as arguments then the
command collects tags from matching messages only.

This could be used by functions in the Emacs mode to further limit the
list of tags offered for completion. For example, functions that remove
tags from message(s) could offer only tags present in the message(s).

Signed-off-by: Jan Janak <jan@ryngle.com>
2009-11-26 07:06:41 -08:00
Jan Janak
f8baa02335 notmuch: New command 'search-tags'.
This is a new notmuch command that can be used to search for all tags
found in the database. The resulting list is alphabetically sorted.

The primary use-case for this new command is to provide the tag
completion feature in Emacs (and other interfaces).

Signed-off-by: Jan Janak <jan@ryngle.com>
2009-11-26 07:02:48 -08:00