mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
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.
This commit is contained in:
parent
06a64cf0aa
commit
319efe21c9
15 changed files with 38 additions and 33 deletions
|
@ -171,46 +171,46 @@ void
|
|||
notmuch_exit_if_unsupported_format (void);
|
||||
|
||||
int
|
||||
notmuch_count_command (notmuch_config_t *config, int argc, char *argv[]);
|
||||
notmuch_count_command (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
int
|
||||
notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[]);
|
||||
notmuch_dump_command (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
int
|
||||
notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]);
|
||||
notmuch_new_command (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
int
|
||||
notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]);
|
||||
notmuch_insert_command (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
int
|
||||
notmuch_reindex_command (notmuch_config_t *config, int argc, char *argv[]);
|
||||
notmuch_reindex_command (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
int
|
||||
notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[]);
|
||||
notmuch_reply_command (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
int
|
||||
notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[]);
|
||||
notmuch_restore_command (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
int
|
||||
notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]);
|
||||
notmuch_search_command (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
int
|
||||
notmuch_address_command (notmuch_config_t *config, int argc, char *argv[]);
|
||||
notmuch_address_command (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
int
|
||||
notmuch_setup_command (notmuch_config_t *config, int argc, char *argv[]);
|
||||
notmuch_setup_command (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
int
|
||||
notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]);
|
||||
notmuch_show_command (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
int
|
||||
notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[]);
|
||||
notmuch_tag_command (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
int
|
||||
notmuch_config_command (notmuch_config_t *config, int argc, char *argv[]);
|
||||
notmuch_config_command (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
int
|
||||
notmuch_compact_command (notmuch_config_t *config, int argc, char *argv[]);
|
||||
notmuch_compact_command (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
const char *
|
||||
notmuch_time_relative_date (const void *ctx, time_t then);
|
||||
|
|
|
@ -27,7 +27,7 @@ status_update_cb (const char *msg, unused (void *closure))
|
|||
}
|
||||
|
||||
int
|
||||
notmuch_compact_command (notmuch_config_t *config, int argc, char *argv[])
|
||||
notmuch_compact_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[])
|
||||
{
|
||||
const char *path = notmuch_config_get_database_path (config);
|
||||
const char *backup_path = NULL;
|
||||
|
|
|
@ -1102,7 +1102,7 @@ notmuch_config_command_list (notmuch_config_t *config)
|
|||
}
|
||||
|
||||
int
|
||||
notmuch_config_command (notmuch_config_t *config, int argc, char *argv[])
|
||||
notmuch_config_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
int opt_index;
|
||||
|
|
|
@ -148,7 +148,7 @@ count_file (notmuch_database_t *notmuch, FILE *input, const char **exclude_tags,
|
|||
}
|
||||
|
||||
int
|
||||
notmuch_count_command (notmuch_config_t *config, int argc, char *argv[])
|
||||
notmuch_count_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[])
|
||||
{
|
||||
notmuch_database_t *notmuch;
|
||||
char *query_str;
|
||||
|
|
|
@ -361,7 +361,7 @@ notmuch_database_dump (notmuch_database_t *notmuch,
|
|||
}
|
||||
|
||||
int
|
||||
notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[])
|
||||
notmuch_dump_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[])
|
||||
{
|
||||
notmuch_database_t *notmuch;
|
||||
const char *query_str = NULL;
|
||||
|
|
|
@ -444,7 +444,7 @@ add_file (notmuch_database_t *notmuch, const char *path, tag_op_list_t *tag_ops,
|
|||
}
|
||||
|
||||
int
|
||||
notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])
|
||||
notmuch_insert_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[])
|
||||
{
|
||||
notmuch_status_t status, close_status;
|
||||
notmuch_database_t *notmuch;
|
||||
|
|
|
@ -1043,7 +1043,7 @@ print_results (const add_files_state_t *state)
|
|||
}
|
||||
|
||||
int
|
||||
notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
|
||||
notmuch_new_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[])
|
||||
{
|
||||
notmuch_database_t *notmuch;
|
||||
add_files_state_t add_files_state = {
|
||||
|
|
|
@ -83,7 +83,7 @@ reindex_query (notmuch_database_t *notmuch, const char *query_string,
|
|||
}
|
||||
|
||||
int
|
||||
notmuch_reindex_command (notmuch_config_t *config, int argc, char *argv[])
|
||||
notmuch_reindex_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[])
|
||||
{
|
||||
char *query_string = NULL;
|
||||
notmuch_database_t *notmuch;
|
||||
|
|
|
@ -700,7 +700,7 @@ do_reply (notmuch_config_t *config,
|
|||
}
|
||||
|
||||
int
|
||||
notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])
|
||||
notmuch_reply_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[])
|
||||
{
|
||||
notmuch_database_t *notmuch;
|
||||
notmuch_query_t *query;
|
||||
|
|
|
@ -219,7 +219,7 @@ parse_sup_line (void *ctx, char *line,
|
|||
}
|
||||
|
||||
int
|
||||
notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
|
||||
notmuch_restore_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[])
|
||||
{
|
||||
notmuch_database_t *notmuch;
|
||||
bool accumulate = false;
|
||||
|
|
|
@ -805,7 +805,7 @@ static const notmuch_opt_desc_t common_options[] = {
|
|||
};
|
||||
|
||||
int
|
||||
notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
|
||||
notmuch_search_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[])
|
||||
{
|
||||
search_context_t *ctx = &search_context;
|
||||
int opt_index, ret;
|
||||
|
@ -871,7 +871,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
}
|
||||
|
||||
int
|
||||
notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])
|
||||
notmuch_address_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[])
|
||||
{
|
||||
search_context_t *ctx = &search_context;
|
||||
int opt_index, ret;
|
||||
|
|
|
@ -122,6 +122,7 @@ parse_tag_list (void *ctx, char *response)
|
|||
|
||||
int
|
||||
notmuch_setup_command (notmuch_config_t *config,
|
||||
unused(notmuch_database_t *notmuch),
|
||||
int argc, char *argv[])
|
||||
{
|
||||
char *response = NULL;
|
||||
|
|
|
@ -1215,7 +1215,7 @@ static const notmuch_show_format_t *formatters[] = {
|
|||
};
|
||||
|
||||
int
|
||||
notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
|
||||
notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[])
|
||||
{
|
||||
notmuch_database_t *notmuch;
|
||||
notmuch_query_t *query;
|
||||
|
|
|
@ -187,7 +187,7 @@ tag_file (void *ctx, notmuch_database_t *notmuch, tag_op_flag_t flags,
|
|||
}
|
||||
|
||||
int
|
||||
notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[])
|
||||
notmuch_tag_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[])
|
||||
{
|
||||
tag_op_list_t *tag_ops = NULL;
|
||||
char *query_string = NULL;
|
||||
|
|
16
notmuch.c
16
notmuch.c
|
@ -27,8 +27,11 @@
|
|||
*
|
||||
* The return value will be used as notmuch exit status code,
|
||||
* preferably EXIT_SUCCESS or EXIT_FAILURE.
|
||||
*
|
||||
* Each subcommand should be passed either a config object, or an open
|
||||
* database
|
||||
*/
|
||||
typedef int (*command_function_t) (notmuch_config_t *config, int argc, char *argv[]);
|
||||
typedef int (*command_function_t) (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
typedef struct command {
|
||||
const char *name;
|
||||
|
@ -38,10 +41,10 @@ typedef struct command {
|
|||
} command_t;
|
||||
|
||||
static int
|
||||
notmuch_help_command (notmuch_config_t *config, int argc, char *argv[]);
|
||||
notmuch_help_command (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
static int
|
||||
notmuch_command (notmuch_config_t *config, int argc, char *argv[]);
|
||||
notmuch_command (notmuch_config_t *config, notmuch_database_t *notmuch, int argc, char *argv[]);
|
||||
|
||||
static int
|
||||
_help_for (const char *topic);
|
||||
|
@ -335,7 +338,7 @@ _help_for (const char *topic_name)
|
|||
}
|
||||
|
||||
static int
|
||||
notmuch_help_command (unused (notmuch_config_t *config), int argc, char *argv[])
|
||||
notmuch_help_command (unused (notmuch_config_t *config), unused(notmuch_database_t *notmuch), int argc, char *argv[])
|
||||
{
|
||||
int opt_index;
|
||||
|
||||
|
@ -360,6 +363,7 @@ notmuch_help_command (unused (notmuch_config_t *config), int argc, char *argv[])
|
|||
*/
|
||||
static int
|
||||
notmuch_command (notmuch_config_t *config,
|
||||
unused(notmuch_database_t *notmuch),
|
||||
unused(int argc), unused(char **argv))
|
||||
{
|
||||
char *db_path;
|
||||
|
@ -369,7 +373,7 @@ notmuch_command (notmuch_config_t *config,
|
|||
* notmuch_setup_command which will give a nice welcome message,
|
||||
* and interactively guide the user through the configuration. */
|
||||
if (notmuch_config_is_new (config))
|
||||
return notmuch_setup_command (config, 0, NULL);
|
||||
return notmuch_setup_command (config, NULL, 0, NULL);
|
||||
|
||||
/* Notmuch is already configured, but is there a database? */
|
||||
db_path = talloc_asprintf (config, "%s/%s",
|
||||
|
@ -502,7 +506,7 @@ main (int argc, char *argv[])
|
|||
goto DONE;
|
||||
}
|
||||
|
||||
ret = (command->function)(config, argc - opt_index, argv + opt_index);
|
||||
ret = (command->function)(config, NULL, argc - opt_index, argv + opt_index);
|
||||
|
||||
DONE:
|
||||
if (config)
|
||||
|
|
Loading…
Reference in a new issue