Commit graph

16 commits

Author SHA1 Message Date
David Bremner
f118ef3c3d cli/compact: convert to new configuration framework
Switch to the newly created API function notmuch_database_compact_db,
which takes the database opened in main().
2021-02-06 19:36:06 -04: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
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
Jani Nikula
4a6721970a cli: use designated initializers for opt desc
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-10-04 22:00:42 -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
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
89fe006ca4 cli: initialize quiet variable in compact
Surprisingly there's no compiler warning!
2014-01-13 14:30:27 -04:00
Tomi Ollila
4d5986e8ad compact: tidy formatting
Notmuch compact code whitespace changes to match devel/STYLE.
2013-11-17 20:25:25 -04:00
Jani Nikula
0e04bda2a9 cli: add compact --quiet option and silence output with it
Provide a way to silence the output.
2013-11-07 19:16:06 -04:00
Jani Nikula
54e7f1777d cli: add compact --backup=DIRECTORY option, don't backup by default
It's the user's decision. The recommended way is to do a database dump
anyway. Clean up the relevant printfs too.
2013-11-07 06:58:58 -04:00
Jani Nikula
d34be29a41 cli: return error status if compaction fails
As is customary for any tool.
2013-11-07 06:54:53 -04:00
Jani Nikula
00d2ac2b41 lib: use the compaction backup path provided by the caller
The extra path component added by the lib is a magic value that the
caller just has to know. This is demonstrated by the current code,
which indeed has "xapian.old" both sides of the interface. Use the
backup path provided by the lib caller verbatim, without adding
anything to it.
2013-11-07 06:51:16 -04:00
Jani Nikula
180dba66e4 lib: add closure parameter to compact status update callback
This provides much more flexibility for the caller.
2013-11-07 06:46:42 -04:00
Ben Gamari
241a88ce2f notmuch-compact: Initial commit of CLI
Introduce the user command exposing the new compaction facility.

Signed-off-by: Ben Gamari <bgamari.foss@gmail.com>
2013-10-09 21:47:13 -03:00