aboutsummaryrefslogtreecommitdiff
path: root/notmuch.c
AgeCommit message (Collapse)Author
2017-10-04cli: use designated initializers for opt descJani Nikula
Several changes at once, just to not have to change the same lines several times over: - Use designated initializers to initialize opt desc arrays. - Only initialize the needed fields. - Remove arg_id (short options) as unused. - Replace opt_type and output_var with several type safe output variables, where the output variable being non-NULL determines the type. Introduce checks to ensure only one is set. The downside is some waste of const space per argument; this could be saved by retaining opt_type and using a union, but that's still pretty verbose. - Fix some variables due to the type safety. Mostly a good thing, but leads to some enums being changed to ints. This is pedantically correct, but somewhat annoying. We could also cast, but that defeats the purpose a bit. - Terminate the opt desc arrays using {}. The output variable type safety and the ability to add new fields for just some output types or arguments are the big wins. For example, if we wanted to add a variable to set when the argument is present, we could do so for just the arguments that need it. Beauty is in the eye of the beholder, but I think this looks nice when defining the arguments, and reduces some of the verbosity we have there.
2017-08-01add "notmuch reindex" subcommandDaniel Kahn Gillmor
This new subcommand takes a set of search terms, and re-indexes the list of matching messages.
2017-02-28cli/config: don't try to open config file for 'notmuch help'Jani Nikula
The help command does not really need to try to open the config file. So don't.
2016-10-31cli: try to run external notmuch- prefixed commands as subcommandsJani Nikula
If the given subcommand is not known to notmuch, try to execute external notmuch-<subcommand> instead. This allows users to have their own notmuch related tools be run via the notmuch command, not unlike git does. Also notmuch-emacs-mua will be executable via 'notmuch emacs-mua'. By design, this does not allow notmuch's own subcommands to be overriden using external commands.
2016-06-05Use https instead of http where possibleDaniel Kahn Gillmor
Many of the external links found in the notmuch source can be resolved using https instead of http. This changeset addresses as many as i could find, without touching the e-mail corpus or expected outputs found in tests.
2015-08-14cli: add global option "--uuid"David Bremner
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-07-30cli: enable notmuch --help commandDavid Bremner
This functionality seems to have been undocumented, if it ever existed. Document it now.
2015-06-01cli: add standard option processing to config, help and setupDavid Bremner
In particular this fixes a recently encountered bug where the "--config" argument to "notmuch setup" is silently ignored, which the unpleasant consequence of overwriting the users config file.
2015-06-01cli: define shared options, use for --help and --versionDavid Bremner
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-01cli: refactor notmuch_help_commandDavid Bremner
Create a new private entry point _help_for so that we can call help without simulating a command line invokation to set up the arguments.
2015-06-01cli: ignore config argument of notmuch_help_commandDavid Bremner
We call it with NULL at one point anyway, so it needs to work with NULL. Since the only place we use talloc is right before exec, there is no harm in always using NULL.
2015-05-31cli: change "setup" to "set up" where used as a verbJ. Lewis Muir
The word "setup" is a noun, not a verb. Change occurrences of "setup" where used as a verb to "set up".
2015-03-11cli: add support for notmuch command --helpJani Nikula
Recognize 'notmuch command --help' at the top level as a special case, and show help for the command. Note that for simplicity, --help is only recognized as the first option for the subcommand.
2015-03-11cli: fix top level --help combined with other optionsJani Nikula
If the top level --help is combined with other options, help fails. For example: $ notmuch --version --help Sorry, --help is not a known command. There's not much I can do to help. Fix this by adjusting argc and argv appropriately. The help command ignores argv[0] anyway, so we don't have to set it to "help".
2014-11-05cli: Introduce "notmuch address" commandMichal Sojka
This moves address-related functionality from search command to the new address command. The implementation shares almost all code and some command line options. Options --offset and --limit were intentionally not included in the address command, because they refer to messages numbers, which users do not see in the output. This could confuse users because, for example, they could see more addresses in the output that what was specified with --limit. This functionality can be correctly reimplemented for address subcommand later. Also useless values of --exclude flag were not included in the address command. This was inspired by a patch from Jani Nikula.
2014-03-27cli: fix notmuch help additional topicsJani Nikula
The help for hooks was missing.
2014-01-18cli: close config and do talloc report also on errorsJani Nikula
Seems like the sensible thing to do.
2014-01-18cli: clean up exit status code returned by the cli commandsJani Nikula
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.
2013-11-08cli: Separate current and deprecated format versionAustin Clements
Previously, the CLI would print a deprecation warning if a client requested any format version other than the current one. However, if we add fields that are backwards-compatible, but want clients to be able to depend on, we need to bump the version, but that doesn't make the older version deprecated. Hence, separate out the "minimum active" version and only print a warning for requests below this version number.
2013-10-09notmuch-compact: Initial commit of CLIBen Gamari
Introduce the user command exposing the new compaction facility. Signed-off-by: Ben Gamari <bgamari.foss@gmail.com>
2013-09-14lib/cli: pass GMIME_ENABLE_RFC2047_WORKAROUNDS to g_mime_init()Jani Nikula
As explained by Jeffrey Stedfast, the author of GMime, quoted in [1]: > Passing the GMIME_ENABLE_RFC2047_WORKAROUNDS flag to g_mime_init() > *should* solve the decoding problem mentioned in the thread. This > flag should be safe to pass into g_mime_init() without any bad side > effects and my unit tests do test that code-path. The thread being referred to is [2]. [1] id:87bo56viyo.fsf@nikula.org [2] id:08cb1dcd-c5db-4e33-8b09-7730cb3d59a2@gmail.com
2013-06-29cli: add insert commandPeter Wang
The notmuch insert command reads a message from standard input, writes it to a Maildir folder, and then incorporates the message into the notmuch database. Essentially it moves the functionality of notmuch-deliver into notmuch. Though it could be used as an alternative to notmuch new, the reason I want this is to allow my notmuch frontend to add postponed or sent messages to the mail store and notmuch database, without resorting to another tool (e.g. notmuch-deliver) nor directly modifying the maildir.
2013-06-24revert: Removed top level --stderr= optionTomi Ollila
While looked good on paper, its attempted use caused confusion, complexity, and potential for information leak when passed through wrapper scripts. For slimmer code and to lessen demand for maintenance/support the set of commits which added top level --stderr= option is now reverted.
2013-06-08cli: Guard deprecated g_type_init callsTomi Ollila
g_type_init was deprecated in GLib 2.35.1. In order to compile cleanly, guard these with a suitable #if. (commit msg from https://bugs.freedesktop.org/attachment.cgi?id=73774 )
2013-05-31cli: remove unused argument descriptionsJani Nikula
Clean up leftovers from help system rework. These are no longer needed. They are easy to resurrect and update if a need later arises.
2013-05-29cli: add global option --stderr=FILETomi Ollila
With this option all writes to stderr are redirected to the specified FILE (or to stdout on case FILE is '-'). This is immediately useful in emacs interface as some of its exec intefaces do not provide separation of stdout and stderr.
2013-03-08cli: add top level --config=FILE optionJani Nikula
Let the user specify the config file on the command line.
2013-03-08cli: move config open/close to main() from subcommandsJani Nikula
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-07cli: config: make notmuch_config_open() "is new" parameter input onlyJani Nikula
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-07cli: plug main notmuch command into subcommand machineryJani Nikula
This allows top level arguments to be added to notmuch in a way that doesn't require special handling for the plain notmuch command without a subcommand.
2013-03-07cli: abstract subcommand finding into a new functionJani Nikula
Clean up code.
2013-02-08CLI: add simple error handling for talloc loggingDavid Bremner
This really should have been there before. I think it's better to do the actual operation and then possibly fail writing the memory log, but it would not be too hard to change it to abort earlier.
2013-01-22CLI: convert top level argument parsing to use command-line-argumentsDavid Bremner
This isn't really a win for conciseness yet, but will make it easier to add options.
2013-01-22CLI: remove alias machinery, and "part", "search-tags" commandsDavid Bremner
The commands are long deprecated, so removal is probably overdue. The real motivation is to simplify argument handling for notmuch so that we can migrate to the common argument parsing framework.
2012-12-30CLI: add talloc leak report, controlled by an environment variable.David Bremner
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-16cli: Framework for structured output versioningAustin Clements
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-04cli: fix notmuch top level argument parsingJani Nikula
Use strcmp instead of STRNCMP_LITERAL, which matches the prefix instead of the whole argument.
2011-12-31notmuch: replace built-in help with exec of manDavid Bremner
"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-11cli: add support for pre and post notmuch new hooksJani Nikula
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-11-25CLI: update call to notmuch_help_command for new calling conventions.David Bremner
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-15cli: add support for --output parameter in notmuch countJani Nikula
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-15cli: add options --offset and --limit to notmuch searchJani Nikula
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-10-23docs: Update news, man page, and online help for restore --accumulateDavid Bremner
As a side effect, reformat the NEWs entry for notmuch dump for consistency with the notmuch restore NEWS submitted by Thomas Schwinge.
2011-10-22cli: change argument parsing convention for subcommandsDavid Bremner
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-16docs: Update man page, NEWS and online help for new dump arguments.David Bremner
We mention in all three places that using the filename argument is deprecated.
2011-09-10Add missing call to g_type_init()Aaron Ecay
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-06-23fix sum moar typos [user-visible documentation in code]Pieter Praet
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-05-27Add decryption of PGP/MIME-encrypted parts with --decrypt.Jameson Graef Rollins
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-27Add signature verification of PGP/MIME-signed parts with --verify.Jameson Graef Rollins
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-24notmuch: Implement search-tags as an alias for "search --output=tags *"Carl Worth
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.