mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-24 20:08:10 +01:00
CLI: move query syntax to shared option
This will allow easy addition of a query syntax option to other subcommands.
This commit is contained in:
parent
551254eb76
commit
a2e7af5b69
3 changed files with 16 additions and 5 deletions
|
@ -487,6 +487,8 @@ print_status_gzbytes (const char *loc,
|
|||
|
||||
extern const notmuch_opt_desc_t notmuch_shared_options [];
|
||||
|
||||
notmuch_query_syntax_t shared_option_query_syntax ();
|
||||
|
||||
void notmuch_process_shared_options (notmuch_database_t *notmuch, const char *subcommand_name);
|
||||
int notmuch_minimal_options (const char *subcommand_name,
|
||||
int argc, char **argv);
|
||||
|
|
|
@ -722,7 +722,8 @@ _notmuch_search_prepare (search_context_t *ctx, int argc, char *argv[])
|
|||
|
||||
if (print_status_database ("notmuch search", ctx->notmuch,
|
||||
notmuch_query_create_with_syntax (ctx->notmuch, query_str,
|
||||
ctx->query_syntax, &ctx->query)))
|
||||
shared_option_query_syntax (),
|
||||
&ctx->query)))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
notmuch_query_set_sort (ctx->query, ctx->sort);
|
||||
|
@ -788,10 +789,6 @@ static const notmuch_opt_desc_t common_options[] = {
|
|||
{ "text", NOTMUCH_FORMAT_TEXT },
|
||||
{ "text0", NOTMUCH_FORMAT_TEXT0 },
|
||||
{ 0, 0 } } },
|
||||
{ .opt_keyword = &search_context.query_syntax, .name = "query", .keywords =
|
||||
(notmuch_keyword_t []){ { "infix", NOTMUCH_QUERY_SYNTAX_XAPIAN },
|
||||
{ "sexp", NOTMUCH_QUERY_SYNTAX_SEXP },
|
||||
{ 0, 0 } } },
|
||||
{ .opt_int = ¬much_format_version, .name = "format-version" },
|
||||
{ }
|
||||
};
|
||||
|
|
12
notmuch.c
12
notmuch.c
|
@ -54,14 +54,26 @@ notmuch_exit_if_unmatched_db_uuid (notmuch_database_t *notmuch);
|
|||
|
||||
static bool print_version = false, print_help = false;
|
||||
static const char *notmuch_requested_db_uuid = NULL;
|
||||
static int query_syntax = NOTMUCH_QUERY_SYNTAX_XAPIAN;
|
||||
|
||||
const notmuch_opt_desc_t notmuch_shared_options [] = {
|
||||
{ .opt_bool = &print_version, .name = "version" },
|
||||
{ .opt_bool = &print_help, .name = "help" },
|
||||
{ .opt_string = ¬much_requested_db_uuid, .name = "uuid" },
|
||||
{ .opt_keyword = &query_syntax, .name = "query", .keywords =
|
||||
(notmuch_keyword_t []){ { "infix", NOTMUCH_QUERY_SYNTAX_XAPIAN },
|
||||
{ "sexp", NOTMUCH_QUERY_SYNTAX_SEXP },
|
||||
{ 0, 0 } } },
|
||||
|
||||
{ }
|
||||
};
|
||||
|
||||
notmuch_query_syntax_t
|
||||
shared_option_query_syntax ()
|
||||
{
|
||||
return query_syntax;
|
||||
}
|
||||
|
||||
/* any subcommand wanting to support these options should call
|
||||
* inherit notmuch_shared_options and call
|
||||
* notmuch_process_shared_options (notmuch, subcommand_name);
|
||||
|
|
Loading…
Reference in a new issue