Commit graph

34 commits

Author SHA1 Message Date
David Bremner
d447b694b4 CLI: make variable n_requested_db_uuid file scope.
It turns out that now that we pass an open database into the
subcommands, it is easy to check any requested uuid against the
database at the same time as we process the other shared
arguments. This results in overall less boilerplate code, as well as
making a CLI scope function and variable file scope in notmuch.c.
2021-09-04 17:07:19 -07:00
Simon Branch
e8fa42a97a cli: remove extraneous space in message 2021-07-30 10:05:44 -03:00
David Bremner
1459217e17 CLI: rename notmuch_config_t to notmuch_conffile_t
The name is a compromise between keeping function names from getting
too long, and avoiding confusion with the newer notmuch_config library
API. Try to make clear that the residual functionality is only about
updating configuration files.
2021-04-06 21:32:36 -03:00
David Bremner
1c747a501c CLI: drop notmuch_config_t from subcommand interface.
At this point it is unused in all subcommands.
2021-04-06 21:32:36 -03:00
David Bremner
ec4b7efbe4 CLI/config: remove calls to notmuch_config_open from top level
This will allow simplifying the subcommand interface.

Change the internal API to notmuch_config_open to not tie it to the
implementation of subcommands in notmuch.c.

It also fixes a previously broken test, since notmuch_config_open does
not understand the notion of the empty string as a config file name.
2021-04-06 21:32:36 -03:00
David Bremner
34f734e26b CLI/setup: switch to new configuration framework
Most of the changes are the elimination of notmuch_config_t accessor
use. We also migrate some of the diagnostics to the top level where we
are opening the files in question.
2021-03-27 09:26:14 -03:00
David Bremner
319efe21c9 CLI: add (unused) database argument to subcommands.
This will allow transitioning individual subcommands to the new
configuration framework. Eventually when they are all converted we can
remove the notmuch_config_t * argument.

For now, live with the parameter shadowing in some some subcommands;
it will go away when they are converted.
2021-02-06 19:05:19 -04:00
uncrustify
33382c2b5b cli: run uncrustify
This is the result of running

     $ uncrustify --replace --config devel/uncrustify.cfg *.c *.h

in the top level source directory
2019-06-14 07:41:27 -03:00
Tomi Ollila
38dacf009c append _unused to the expression defined using unused() macro
This way if variables defined using unused() macro are actually
used then code will not compile...

- removed unused usage around one argc and one argv since those
  were used

- changed one unused (char *argv[]) to unused (char **argv) to
  work with modified unused() macro definition
2019-06-11 07:25:04 -03:00
Jani Nikula
0f314c0c99 cli: convert notmuch_bool_t to stdbool
C99 stdbool turned 18 this year. There really is no reason to use our
own, except in the library interface for backward
compatibility. Convert the cli and test binaries to stdbool.
2017-10-09 22:24:02 -03:00
Daniel Kahn Gillmor
6a833a6e83 Use https instead of http where possible
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.
2016-06-05 08:32:17 -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
447ad6b498 cli: add standard option processing to config, help and setup
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-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
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
David Bremner
4b3af0e444 Make exclusion visible again
This reverts

dfee0f9 man: remove search.exclude_tags from notmuch-config.1 for 0.12
e83409d NEWS: revert NEWS item for exclude tags for 0.12
e77b031 config: disable addition of exclude tags for 0.12
2012-03-03 11:56:47 -04:00
Mark Walters
e77b031a86 config: disable addition of exclude tags for 0.12
This disables the addition of search_exclude_tags in notmuch-setup and
notmuch-config.
2012-03-02 19:11:35 -04:00
Pieter Praet
e1da28742d setup: prompt user for search.exclude_tags value
Allow users to customize the search.exclude_tags option during setup.
2012-01-23 19:24:59 -04:00
Austin Clements
ed6f941c2a setup: Create functions for tag list printing and parsing
This refactors the tag list printing and parsing currently used for
new.tags so that both can be reused for the new search.exclude_tags
option.
2012-01-23 19:22:57 -04:00
Carl Worth
ebe733632d notmuch setup: Don't prompt about maildir synchronization
This synchronization is one of those features that should just happen
automatically. We allow for customization in case someone *really*
wants to turn it off, but we don't need to prompt for this
interactively.

People with special needs can find the configuration file on their
own.
2010-11-11 03:53:14 -08:00
Carl Worth
4cfb2a0277 Avoid abbreviation, preferring notmuch_config_get_maildir_synchronize_flags
Since the name of the configuration parameter here is:

	maildir.synchronize_flags

the convention is that the functions to get and set this parameter
should match it in name. Hence:

       notmuch_config_get_maildir_synchronize_flags

etc. (as opposed to notmuch_config_get_maildir_sync).
2010-11-11 03:40:19 -08:00
Michal Sojka
d9d3d3e6f0 Make maildir synchronization configurable
This adds group [maildir] and key 'synchronize_flags' to the
configuration file. Its value enables (true) or diables (false) the
synchronization between notmuch tags and maildir flags. By default,
the synchronization is disabled.
2010-11-10 13:09:32 -08:00
Mike Kelly
14f1a79f44 notmuch-setup.c: Initialize getline(3) response_size to 0
This appears to be necessary on FreeBSD. If this isn't done, we get a
nasty segfault.

See: id:20101013094340.41580a2f@pioto.org
2010-10-29 13:13:02 -07:00
Carl Worth
c6e70e15ea notmuch: Eliminate some const-correctness warnings.
These were introduced as a side-effect of commit
b9eac48c22 (shame on me for doing
side-effect commits like that!).

For me, at least, compilation is now warning-free.
2010-10-27 18:07:37 -07:00
Carl Worth
14fb9f3c55 notmuch setup: Prompt for tags to set on new messages.
Our "notmuch setup" command is only really helpful if it guides the
user through all the possible options. So add this one.
2010-04-23 10:30:40 -07:00
Carl Worth
eb0cf86c7a notmuch setup: Exit if EOF is encountered at any prompt.
If the user is explicitly providing EOF, then terminating the program
is the most likely desired thing to do. This also avoids undefined
behavior from continuing with an uninitialized response after ignoring
the return value of getline().
2009-12-01 08:06:09 -08:00
Jameson Graef Rollins
34c840a23e modify notmuch_setup_command to return 1 if config file write fails.
This fixes a small bug in notmuch_setup_command such that it returned
OK and output the setup message footer even if the config file write
step failed.
2009-11-25 19:24:27 -08:00
Alec Berryman
91d1d3f043 Support multiple configuration files via $NOTMUCH_CONFIG
If present, $NOTMUCH_CONFIG will be used as the configuration file
location.
2009-11-23 03:01:57 +01:00
Carl Worth
37bdd89870 notmuch new: Unbreak after the addition of notmuch-config.
Pull in the code from add-files.c now that notmuch_new_command is
the only user, (we no longer have notmuch_setup_command adding any
messages).
2009-11-11 19:50:15 -08:00
Carl Worth
6bd01e1b34 notmuch: Move welcome messages from "notmuch" to "notmuch setup".
It's quite possible for someone to read the documentation and run
"notmuch setup" rather than just "notmuch". In that case, we don't
want to be any less welcoming.
2009-11-11 17:33:31 -08:00
Carl Worth
305e76bc0a notmuch: Add a configuration system.
This will allow for things like the database path to be specified
without any cheesy NOTMUCH_BASE environment variable. It also will
allow "notmuch reply" to recognize the user's email address when
constructing a reply in order to do the right thing, (that is, to use
the user's address to which mail was sent as From:, and not to reply
to the user's own addresses).

With this change, the "notmuch setup" command is now strictly for
changing the configuration of notmuch. It no longer creates the
database, but instead instructs the user to call "notmuch new" to do
that.
2009-11-11 17:01:55 -08:00
Carl Worth
69611e66a5 notmuch setup: Break the implementation up into manageable functions.
The notmuch_setup_command function was getting entirely unwieldy.
Break it up into smaller functions for better maintainability.
2009-11-11 11:23:55 -08:00
Carl Worth
50144f95ca notmuch: Break notmuch.c up into several smaller files.
Now that the client sources are alone here in their own directory,
(with all the library sources down inside the lib directory), we can
break the client up into multiple files without mixing the files up.
The hope is that these smaller files will be easier to manage and
maintain.
2009-11-10 12:03:05 -08:00