aboutsummaryrefslogtreecommitdiffhomepage
path: root/notmuch-show.c
diff options
context:
space:
mode:
authorGravatar Jani Nikula <jani@nikula.org>2013-03-03 23:55:09 +0200
committerGravatar David Bremner <bremner@debian.org>2013-03-08 07:54:41 -0400
commit4ef2106792439f5ade157b3ba3b8f7fa86fcb3ed (patch)
tree892c4e1a8826b324eea1492d19b156b46ae95a06 /notmuch-show.c
parente76f6517de020783d828be59f461f1d4f465c4b4 (diff)
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.
Diffstat (limited to 'notmuch-show.c')
-rw-r--r--notmuch-show.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/notmuch-show.c b/notmuch-show.c
index 5ae5d7de..c2ec122c 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1056,9 +1056,8 @@ enum {
};
int
-notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
+notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
{
- notmuch_config_t *config;
notmuch_database_t *notmuch;
notmuch_query_t *query;
char *query_string;
@@ -1176,11 +1175,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
else
params.entire_thread = FALSE;
- config = notmuch_config_open (ctx, NULL, FALSE);
- if (config == NULL)
- return 1;
-
- query_string = query_string_from_args (ctx, argc-opt_index, argv+opt_index);
+ query_string = query_string_from_args (config, argc-opt_index, argv+opt_index);
if (query_string == NULL) {
fprintf (stderr, "Out of memory\n");
return 1;
@@ -1202,11 +1197,11 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
}
/* Create structure printer. */
- sprinter = format->new_sprinter(ctx, stdout);
+ sprinter = format->new_sprinter(config, stdout);
/* If a single message is requested we do not use search_excludes. */
if (params.part >= 0)
- ret = do_show_single (ctx, query, format, sprinter, &params);
+ ret = do_show_single (config, query, format, sprinter, &params);
else {
/* We always apply set the exclude flag. The
* exclude=true|false option controls whether or not we return
@@ -1225,7 +1220,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
params.omit_excluded = FALSE;
}
- ret = do_show (ctx, query, format, sprinter, &params);
+ ret = do_show (config, query, format, sprinter, &params);
}
notmuch_crypto_cleanup (&params.crypto);