mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
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.
This commit is contained in:
parent
d57da17fcd
commit
4a6721970a
18 changed files with 185 additions and 187 deletions
|
@ -22,12 +22,10 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char
|
||||||
|
|
||||||
while (keywords->name) {
|
while (keywords->name) {
|
||||||
if (strcmp (arg_str, keywords->name) == 0) {
|
if (strcmp (arg_str, keywords->name) == 0) {
|
||||||
if (arg_desc->output_var) {
|
if (arg_desc->opt_flags)
|
||||||
if (arg_desc->opt_type == NOTMUCH_OPT_KEYWORD_FLAGS)
|
*arg_desc->opt_flags |= keywords->value;
|
||||||
*((int *)arg_desc->output_var) |= keywords->value;
|
|
||||||
else
|
else
|
||||||
*((int *)arg_desc->output_var) = keywords->value;
|
*arg_desc->opt_keyword = keywords->value;
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
keywords++;
|
keywords++;
|
||||||
|
@ -43,15 +41,15 @@ static notmuch_bool_t
|
||||||
_process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
|
_process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
|
||||||
|
|
||||||
if (next == '\0') {
|
if (next == '\0') {
|
||||||
*((notmuch_bool_t *)arg_desc->output_var) = TRUE;
|
*arg_desc->opt_bool = TRUE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (strcmp (arg_str, "false") == 0) {
|
if (strcmp (arg_str, "false") == 0) {
|
||||||
*((notmuch_bool_t *)arg_desc->output_var) = FALSE;
|
*arg_desc->opt_bool = FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (strcmp (arg_str, "true") == 0) {
|
if (strcmp (arg_str, "true") == 0) {
|
||||||
*((notmuch_bool_t *)arg_desc->output_var) = TRUE;
|
*arg_desc->opt_bool = TRUE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
fprintf (stderr, "Unknown argument \"%s\" for (boolean) option \"%s\".\n", arg_str, arg_desc->name);
|
fprintf (stderr, "Unknown argument \"%s\" for (boolean) option \"%s\".\n", arg_str, arg_desc->name);
|
||||||
|
@ -67,7 +65,7 @@ _process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
*((int *)arg_desc->output_var) = strtol (arg_str, &endptr, 10);
|
*arg_desc->opt_int = strtol (arg_str, &endptr, 10);
|
||||||
if (*endptr == '\0')
|
if (*endptr == '\0')
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
@ -87,10 +85,35 @@ _process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *
|
||||||
fprintf (stderr, "String argument for option \"%s\" must be non-empty.\n", arg_desc->name);
|
fprintf (stderr, "String argument for option \"%s\" must be non-empty.\n", arg_desc->name);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
*((const char **)arg_desc->output_var) = arg_str;
|
*arg_desc->opt_string = arg_str;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return number of non-NULL opt_* fields in opt_desc. */
|
||||||
|
static int _opt_set_count (const notmuch_opt_desc_t *opt_desc)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
!!opt_desc->opt_inherit +
|
||||||
|
!!opt_desc->opt_bool +
|
||||||
|
!!opt_desc->opt_int +
|
||||||
|
!!opt_desc->opt_keyword +
|
||||||
|
!!opt_desc->opt_flags +
|
||||||
|
!!opt_desc->opt_string +
|
||||||
|
!!opt_desc->opt_position;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return TRUE if opt_desc is valid. */
|
||||||
|
static notmuch_bool_t _opt_valid (const notmuch_opt_desc_t *opt_desc)
|
||||||
|
{
|
||||||
|
int n = _opt_set_count (opt_desc);
|
||||||
|
|
||||||
|
if (n > 1)
|
||||||
|
INTERNAL_ERROR ("more than one non-NULL opt_* field for argument \"%s\"",
|
||||||
|
opt_desc->name);
|
||||||
|
|
||||||
|
return n > 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Search for the {pos_arg_index}th position argument, return FALSE if
|
Search for the {pos_arg_index}th position argument, return FALSE if
|
||||||
that does not exist.
|
that does not exist.
|
||||||
|
@ -101,12 +124,10 @@ parse_position_arg (const char *arg_str, int pos_arg_index,
|
||||||
const notmuch_opt_desc_t *arg_desc) {
|
const notmuch_opt_desc_t *arg_desc) {
|
||||||
|
|
||||||
int pos_arg_counter = 0;
|
int pos_arg_counter = 0;
|
||||||
while (arg_desc->opt_type != NOTMUCH_OPT_END){
|
while (_opt_valid (arg_desc)) {
|
||||||
if (arg_desc->opt_type == NOTMUCH_OPT_POSITION) {
|
if (arg_desc->opt_position) {
|
||||||
if (pos_arg_counter == pos_arg_index) {
|
if (pos_arg_counter == pos_arg_index) {
|
||||||
if (arg_desc->output_var) {
|
*arg_desc->opt_position = arg_str;
|
||||||
*((const char **)arg_desc->output_var) = arg_str;
|
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
pos_arg_counter++;
|
pos_arg_counter++;
|
||||||
|
@ -138,9 +159,9 @@ parse_option (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_
|
||||||
if (opt_index < argc - 1 && strncmp (argv[opt_index + 1], "--", 2) != 0)
|
if (opt_index < argc - 1 && strncmp (argv[opt_index + 1], "--", 2) != 0)
|
||||||
next_arg = argv[opt_index + 1];
|
next_arg = argv[opt_index + 1];
|
||||||
|
|
||||||
for (try = options; try->opt_type != NOTMUCH_OPT_END; try++) {
|
for (try = options; _opt_valid (try); try++) {
|
||||||
if (try->opt_type == NOTMUCH_OPT_INHERIT) {
|
if (try->opt_inherit) {
|
||||||
int new_index = parse_option (argc, argv, try->output_var, opt_index);
|
int new_index = parse_option (argc, argv, try->opt_inherit, opt_index);
|
||||||
if (new_index >= 0)
|
if (new_index >= 0)
|
||||||
return new_index;
|
return new_index;
|
||||||
}
|
}
|
||||||
|
@ -163,36 +184,24 @@ parse_option (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_
|
||||||
if (next != '=' && next != ':' && next != '\0')
|
if (next != '=' && next != ':' && next != '\0')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (next == '\0' && next_arg != NULL && try->opt_type != NOTMUCH_OPT_BOOLEAN) {
|
if (next == '\0' && next_arg != NULL && ! try->opt_bool) {
|
||||||
next = ' ';
|
next = ' ';
|
||||||
value = next_arg;
|
value = next_arg;
|
||||||
opt_index ++;
|
opt_index ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (try->output_var == NULL)
|
|
||||||
INTERNAL_ERROR ("output pointer NULL for option %s", try->name);
|
|
||||||
|
|
||||||
notmuch_bool_t opt_status = FALSE;
|
notmuch_bool_t opt_status = FALSE;
|
||||||
switch (try->opt_type) {
|
if (try->opt_keyword || try->opt_flags)
|
||||||
case NOTMUCH_OPT_KEYWORD:
|
|
||||||
case NOTMUCH_OPT_KEYWORD_FLAGS:
|
|
||||||
opt_status = _process_keyword_arg (try, next, value);
|
opt_status = _process_keyword_arg (try, next, value);
|
||||||
break;
|
else if (try->opt_bool)
|
||||||
case NOTMUCH_OPT_BOOLEAN:
|
|
||||||
opt_status = _process_boolean_arg (try, next, value);
|
opt_status = _process_boolean_arg (try, next, value);
|
||||||
break;
|
else if (try->opt_int)
|
||||||
case NOTMUCH_OPT_INT:
|
|
||||||
opt_status = _process_int_arg (try, next, value);
|
opt_status = _process_int_arg (try, next, value);
|
||||||
break;
|
else if (try->opt_string)
|
||||||
case NOTMUCH_OPT_STRING:
|
|
||||||
opt_status = _process_string_arg (try, next, value);
|
opt_status = _process_string_arg (try, next, value);
|
||||||
break;
|
else
|
||||||
case NOTMUCH_OPT_POSITION:
|
INTERNAL_ERROR ("unknown or unhandled option \"%s\"", try->name);
|
||||||
case NOTMUCH_OPT_END:
|
|
||||||
default:
|
|
||||||
INTERNAL_ERROR ("unknown or unhandled option type %d", try->opt_type);
|
|
||||||
/*UNREACHED*/
|
|
||||||
}
|
|
||||||
if (opt_status)
|
if (opt_status)
|
||||||
return opt_index+1;
|
return opt_index+1;
|
||||||
else
|
else
|
||||||
|
|
|
@ -3,17 +3,6 @@
|
||||||
|
|
||||||
#include "notmuch.h"
|
#include "notmuch.h"
|
||||||
|
|
||||||
enum notmuch_opt_type {
|
|
||||||
NOTMUCH_OPT_END = 0,
|
|
||||||
NOTMUCH_OPT_INHERIT, /* another options table */
|
|
||||||
NOTMUCH_OPT_BOOLEAN, /* --verbose */
|
|
||||||
NOTMUCH_OPT_INT, /* --frob=8 */
|
|
||||||
NOTMUCH_OPT_KEYWORD, /* --format=raw|json|text */
|
|
||||||
NOTMUCH_OPT_KEYWORD_FLAGS, /* the above with values OR'd together */
|
|
||||||
NOTMUCH_OPT_STRING, /* --file=/tmp/gnarf.txt */
|
|
||||||
NOTMUCH_OPT_POSITION /* notmuch dump pos_arg */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Describe one of the possibilities for a keyword option
|
* Describe one of the possibilities for a keyword option
|
||||||
* 'value' will be copied to the output variable
|
* 'value' will be copied to the output variable
|
||||||
|
@ -24,22 +13,21 @@ typedef struct notmuch_keyword {
|
||||||
int value;
|
int value;
|
||||||
} notmuch_keyword_t;
|
} notmuch_keyword_t;
|
||||||
|
|
||||||
/*
|
/* Describe one option. */
|
||||||
* Describe one option.
|
|
||||||
*
|
|
||||||
* First two parameters are mandatory.
|
|
||||||
*
|
|
||||||
* name is mandatory _except_ for positional arguments.
|
|
||||||
*
|
|
||||||
* arg_id is currently unused, but could define short arguments.
|
|
||||||
*
|
|
||||||
* keywords is a (possibly NULL) pointer to an array of keywords
|
|
||||||
*/
|
|
||||||
typedef struct notmuch_opt_desc {
|
typedef struct notmuch_opt_desc {
|
||||||
enum notmuch_opt_type opt_type;
|
/* One and only one of opt_* must be set. */
|
||||||
void *output_var;
|
const struct notmuch_opt_desc *opt_inherit;
|
||||||
|
notmuch_bool_t *opt_bool;
|
||||||
|
int *opt_int;
|
||||||
|
int *opt_keyword;
|
||||||
|
int *opt_flags;
|
||||||
|
const char **opt_string;
|
||||||
|
const char **opt_position;
|
||||||
|
|
||||||
|
/* Must be set except for opt_inherit and opt_position. */
|
||||||
const char *name;
|
const char *name;
|
||||||
int arg_id;
|
|
||||||
|
/* Must be set for opt_keyword and opt_flags. */
|
||||||
const struct notmuch_keyword *keywords;
|
const struct notmuch_keyword *keywords;
|
||||||
} notmuch_opt_desc_t;
|
} notmuch_opt_desc_t;
|
||||||
|
|
||||||
|
|
|
@ -508,7 +508,7 @@ status_to_exit (notmuch_status_t status);
|
||||||
|
|
||||||
#include "command-line-arguments.h"
|
#include "command-line-arguments.h"
|
||||||
|
|
||||||
extern char *notmuch_requested_db_uuid;
|
extern const char *notmuch_requested_db_uuid;
|
||||||
extern const notmuch_opt_desc_t notmuch_shared_options [];
|
extern const notmuch_opt_desc_t notmuch_shared_options [];
|
||||||
void notmuch_exit_if_unmatched_db_uuid (notmuch_database_t *notmuch);
|
void notmuch_exit_if_unmatched_db_uuid (notmuch_database_t *notmuch);
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,10 @@ notmuch_compact_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
int opt_index;
|
int opt_index;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_STRING, &backup_path, "backup", 0, 0 },
|
{ .opt_string = &backup_path, .name = "backup" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &quiet, "quiet", 'q', 0 },
|
{ .opt_bool = &quiet, .name = "quiet" },
|
||||||
{ NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
|
{ .opt_inherit = notmuch_shared_options },
|
||||||
{ 0, 0, 0, 0, 0}
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
opt_index = parse_arguments (argc, argv, options, 1);
|
opt_index = parse_arguments (argc, argv, options, 1);
|
||||||
|
|
|
@ -166,24 +166,24 @@ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
notmuch_bool_t batch = FALSE;
|
notmuch_bool_t batch = FALSE;
|
||||||
notmuch_bool_t print_lastmod = FALSE;
|
notmuch_bool_t print_lastmod = FALSE;
|
||||||
FILE *input = stdin;
|
FILE *input = stdin;
|
||||||
char *input_file_name = NULL;
|
const char *input_file_name = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_KEYWORD, &output, "output", 'o',
|
{ .opt_keyword = &output, .name = "output", .keywords =
|
||||||
(notmuch_keyword_t []){ { "threads", OUTPUT_THREADS },
|
(notmuch_keyword_t []){ { "threads", OUTPUT_THREADS },
|
||||||
{ "messages", OUTPUT_MESSAGES },
|
{ "messages", OUTPUT_MESSAGES },
|
||||||
{ "files", OUTPUT_FILES },
|
{ "files", OUTPUT_FILES },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x',
|
{ .opt_keyword = &exclude, .name = "exclude", .keywords =
|
||||||
(notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },
|
(notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },
|
||||||
{ "false", EXCLUDE_FALSE },
|
{ "false", EXCLUDE_FALSE },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &print_lastmod, "lastmod", 'l', 0 },
|
{ .opt_bool = &print_lastmod, .name = "lastmod" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &batch, "batch", 0, 0 },
|
{ .opt_bool = &batch, .name = "batch" },
|
||||||
{ NOTMUCH_OPT_STRING, &input_file_name, "input", 'i', 0 },
|
{ .opt_string = &input_file_name, .name = "input" },
|
||||||
{ NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
|
{ .opt_inherit = notmuch_shared_options },
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
opt_index = parse_arguments (argc, argv, options, 1);
|
opt_index = parse_arguments (argc, argv, options, 1);
|
||||||
|
|
|
@ -369,7 +369,7 @@ notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
|
|
||||||
notmuch_exit_if_unmatched_db_uuid (notmuch);
|
notmuch_exit_if_unmatched_db_uuid (notmuch);
|
||||||
|
|
||||||
char *output_file_name = NULL;
|
const char *output_file_name = NULL;
|
||||||
int opt_index;
|
int opt_index;
|
||||||
|
|
||||||
int output_format = DUMP_FORMAT_BATCH_TAG;
|
int output_format = DUMP_FORMAT_BATCH_TAG;
|
||||||
|
@ -377,18 +377,18 @@ notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
notmuch_bool_t gzip_output = 0;
|
notmuch_bool_t gzip_output = 0;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_KEYWORD, &output_format, "format", 'f',
|
{ .opt_keyword = &output_format, .name = "format", .keywords =
|
||||||
(notmuch_keyword_t []){ { "sup", DUMP_FORMAT_SUP },
|
(notmuch_keyword_t []){ { "sup", DUMP_FORMAT_SUP },
|
||||||
{ "batch-tag", DUMP_FORMAT_BATCH_TAG },
|
{ "batch-tag", DUMP_FORMAT_BATCH_TAG },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_KEYWORD_FLAGS, &include, "include", 'I',
|
{ .opt_flags = &include, .name = "include", .keywords =
|
||||||
(notmuch_keyword_t []){ { "config", DUMP_INCLUDE_CONFIG },
|
(notmuch_keyword_t []){ { "config", DUMP_INCLUDE_CONFIG },
|
||||||
{ "properties", DUMP_INCLUDE_PROPERTIES },
|
{ "properties", DUMP_INCLUDE_PROPERTIES },
|
||||||
{ "tags", DUMP_INCLUDE_TAGS} } },
|
{ "tags", DUMP_INCLUDE_TAGS} } },
|
||||||
{ NOTMUCH_OPT_STRING, &output_file_name, "output", 'o', 0 },
|
{ .opt_string = &output_file_name, .name = "output" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &gzip_output, "gzip", 'z', 0 },
|
{ .opt_bool = &gzip_output, .name = "gzip" },
|
||||||
{ NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
|
{ .opt_inherit = notmuch_shared_options },
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
opt_index = parse_arguments (argc, argv, options, 1);
|
opt_index = parse_arguments (argc, argv, options, 1);
|
||||||
|
|
|
@ -463,12 +463,12 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_STRING, &folder, "folder", 0, 0 },
|
{ .opt_string = &folder, .name = "folder" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &create_folder, "create-folder", 0, 0 },
|
{ .opt_bool = &create_folder, .name = "create-folder" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &keep, "keep", 0, 0 },
|
{ .opt_bool = &keep, .name = "keep" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &no_hooks, "no-hooks", 'n', 0 },
|
{ .opt_bool = &no_hooks, .name = "no-hooks" },
|
||||||
{ NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
|
{ .opt_inherit = notmuch_shared_options },
|
||||||
{ NOTMUCH_OPT_END, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
opt_index = parse_arguments (argc, argv, options, 1);
|
opt_index = parse_arguments (argc, argv, options, 1);
|
||||||
|
|
|
@ -959,12 +959,12 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
notmuch_status_t status;
|
notmuch_status_t status;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &quiet, "quiet", 'q', 0 },
|
{ .opt_bool = &quiet, .name = "quiet" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &verbose, "verbose", 'v', 0 },
|
{ .opt_bool = &verbose, .name = "verbose" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &add_files_state.debug, "debug", 'd', 0 },
|
{ .opt_bool = &add_files_state.debug, .name = "debug" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &no_hooks, "no-hooks", 'n', 0 },
|
{ .opt_bool = &no_hooks, .name = "no-hooks" },
|
||||||
{ NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
|
{ .opt_inherit = notmuch_shared_options },
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
opt_index = parse_arguments (argc, argv, options, 1);
|
opt_index = parse_arguments (argc, argv, options, 1);
|
||||||
|
|
|
@ -99,8 +99,8 @@ notmuch_reindex_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
sigaction (SIGINT, &action, NULL);
|
sigaction (SIGINT, &action, NULL);
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
|
{ .opt_inherit = notmuch_shared_options },
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
opt_index = parse_arguments (argc, argv, options, 1);
|
opt_index = parse_arguments (argc, argv, options, 1);
|
||||||
|
|
|
@ -705,20 +705,20 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
int reply_all = TRUE;
|
int reply_all = TRUE;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_KEYWORD, &format, "format", 'f',
|
{ .opt_keyword = &format, .name = "format", .keywords =
|
||||||
(notmuch_keyword_t []){ { "default", FORMAT_DEFAULT },
|
(notmuch_keyword_t []){ { "default", FORMAT_DEFAULT },
|
||||||
{ "json", FORMAT_JSON },
|
{ "json", FORMAT_JSON },
|
||||||
{ "sexp", FORMAT_SEXP },
|
{ "sexp", FORMAT_SEXP },
|
||||||
{ "headers-only", FORMAT_HEADERS_ONLY },
|
{ "headers-only", FORMAT_HEADERS_ONLY },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_INT, ¬much_format_version, "format-version", 0, 0 },
|
{ .opt_int = ¬much_format_version, .name = "format-version" },
|
||||||
{ NOTMUCH_OPT_KEYWORD, &reply_all, "reply-to", 'r',
|
{ .opt_keyword = &reply_all, .name = "reply-to", .keywords =
|
||||||
(notmuch_keyword_t []){ { "all", TRUE },
|
(notmuch_keyword_t []){ { "all", TRUE },
|
||||||
{ "sender", FALSE },
|
{ "sender", FALSE },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 },
|
{ .opt_bool = ¶ms.crypto.decrypt, .name = "decrypt" },
|
||||||
{ NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
|
{ .opt_inherit = notmuch_shared_options },
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
opt_index = parse_arguments (argc, argv, options, 1);
|
opt_index = parse_arguments (argc, argv, options, 1);
|
||||||
|
|
|
@ -227,7 +227,7 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
tag_op_flag_t flags = 0;
|
tag_op_flag_t flags = 0;
|
||||||
tag_op_list_t *tag_ops;
|
tag_op_list_t *tag_ops;
|
||||||
|
|
||||||
char *input_file_name = NULL;
|
const char *input_file_name = NULL;
|
||||||
const char *name_for_error = NULL;
|
const char *name_for_error = NULL;
|
||||||
gzFile input = NULL;
|
gzFile input = NULL;
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
|
@ -247,20 +247,20 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
flags |= TAG_FLAG_MAILDIR_SYNC;
|
flags |= TAG_FLAG_MAILDIR_SYNC;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_KEYWORD, &input_format, "format", 'f',
|
{ .opt_keyword = &input_format, .name = "format", .keywords =
|
||||||
(notmuch_keyword_t []){ { "auto", DUMP_FORMAT_AUTO },
|
(notmuch_keyword_t []){ { "auto", DUMP_FORMAT_AUTO },
|
||||||
{ "batch-tag", DUMP_FORMAT_BATCH_TAG },
|
{ "batch-tag", DUMP_FORMAT_BATCH_TAG },
|
||||||
{ "sup", DUMP_FORMAT_SUP },
|
{ "sup", DUMP_FORMAT_SUP },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_KEYWORD_FLAGS, &include, "include", 'I',
|
{ .opt_flags = &include, .name = "include", .keywords =
|
||||||
(notmuch_keyword_t []){ { "config", DUMP_INCLUDE_CONFIG },
|
(notmuch_keyword_t []){ { "config", DUMP_INCLUDE_CONFIG },
|
||||||
{ "properties", DUMP_INCLUDE_PROPERTIES },
|
{ "properties", DUMP_INCLUDE_PROPERTIES },
|
||||||
{ "tags", DUMP_INCLUDE_TAGS} } },
|
{ "tags", DUMP_INCLUDE_TAGS} } },
|
||||||
|
|
||||||
{ NOTMUCH_OPT_STRING, &input_file_name, "input", 'i', 0 },
|
{ .opt_string = &input_file_name, .name = "input" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &accumulate, "accumulate", 'a', 0 },
|
{ .opt_bool = &accumulate, .name = "accumulate" },
|
||||||
{ NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
|
{ .opt_inherit = notmuch_shared_options },
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
opt_index = parse_arguments (argc, argv, options, 1);
|
opt_index = parse_arguments (argc, argv, options, 1);
|
||||||
|
|
|
@ -51,17 +51,17 @@ typedef enum {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
notmuch_database_t *notmuch;
|
notmuch_database_t *notmuch;
|
||||||
format_sel_t format_sel;
|
int format_sel;
|
||||||
sprinter_t *format;
|
sprinter_t *format;
|
||||||
notmuch_exclude_t exclude;
|
int exclude;
|
||||||
notmuch_query_t *query;
|
notmuch_query_t *query;
|
||||||
notmuch_sort_t sort;
|
int sort;
|
||||||
output_t output;
|
int output;
|
||||||
int offset;
|
int offset;
|
||||||
int limit;
|
int limit;
|
||||||
int dupe;
|
int dupe;
|
||||||
GHashTable *addresses;
|
GHashTable *addresses;
|
||||||
dedup_t dedup;
|
int dedup;
|
||||||
} search_context_t;
|
} search_context_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -786,18 +786,18 @@ static search_context_t search_context = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const notmuch_opt_desc_t common_options[] = {
|
static const notmuch_opt_desc_t common_options[] = {
|
||||||
{ NOTMUCH_OPT_KEYWORD, &search_context.sort, "sort", 's',
|
{ .opt_keyword = &search_context.sort, .name = "sort", .keywords =
|
||||||
(notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },
|
(notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },
|
||||||
{ "newest-first", NOTMUCH_SORT_NEWEST_FIRST },
|
{ "newest-first", NOTMUCH_SORT_NEWEST_FIRST },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_KEYWORD, &search_context.format_sel, "format", 'f',
|
{ .opt_keyword = &search_context.format_sel, .name = "format", .keywords =
|
||||||
(notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
|
(notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
|
||||||
{ "sexp", NOTMUCH_FORMAT_SEXP },
|
{ "sexp", NOTMUCH_FORMAT_SEXP },
|
||||||
{ "text", NOTMUCH_FORMAT_TEXT },
|
{ "text", NOTMUCH_FORMAT_TEXT },
|
||||||
{ "text0", NOTMUCH_FORMAT_TEXT0 },
|
{ "text0", NOTMUCH_FORMAT_TEXT0 },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_INT, ¬much_format_version, "format-version", 0, 0 },
|
{ .opt_int = ¬much_format_version, .name = "format-version" },
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -807,25 +807,25 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
int opt_index, ret;
|
int opt_index, ret;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_KEYWORD, &ctx->output, "output", 'o',
|
{ .opt_keyword = &ctx->output, .name = "output", .keywords =
|
||||||
(notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY },
|
(notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY },
|
||||||
{ "threads", OUTPUT_THREADS },
|
{ "threads", OUTPUT_THREADS },
|
||||||
{ "messages", OUTPUT_MESSAGES },
|
{ "messages", OUTPUT_MESSAGES },
|
||||||
{ "files", OUTPUT_FILES },
|
{ "files", OUTPUT_FILES },
|
||||||
{ "tags", OUTPUT_TAGS },
|
{ "tags", OUTPUT_TAGS },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_KEYWORD, &ctx->exclude, "exclude", 'x',
|
{ .opt_keyword = &ctx->exclude, .name = "exclude", .keywords =
|
||||||
(notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },
|
(notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },
|
||||||
{ "false", NOTMUCH_EXCLUDE_FALSE },
|
{ "false", NOTMUCH_EXCLUDE_FALSE },
|
||||||
{ "flag", NOTMUCH_EXCLUDE_FLAG },
|
{ "flag", NOTMUCH_EXCLUDE_FLAG },
|
||||||
{ "all", NOTMUCH_EXCLUDE_ALL },
|
{ "all", NOTMUCH_EXCLUDE_ALL },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_INT, &ctx->offset, "offset", 'O', 0 },
|
{ .opt_int = &ctx->offset, .name = "offset" },
|
||||||
{ NOTMUCH_OPT_INT, &ctx->limit, "limit", 'L', 0 },
|
{ .opt_int = &ctx->limit, .name = "limit" },
|
||||||
{ NOTMUCH_OPT_INT, &ctx->dupe, "duplicate", 'D', 0 },
|
{ .opt_int = &ctx->dupe, .name = "duplicate" },
|
||||||
{ NOTMUCH_OPT_INHERIT, (void *) &common_options, NULL, 0, 0 },
|
{ .opt_inherit = common_options },
|
||||||
{ NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
|
{ .opt_inherit = notmuch_shared_options },
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx->output = OUTPUT_SUMMARY;
|
ctx->output = OUTPUT_SUMMARY;
|
||||||
|
@ -873,23 +873,23 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
int opt_index, ret;
|
int opt_index, ret;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_KEYWORD_FLAGS, &ctx->output, "output", 'o',
|
{ .opt_flags = &ctx->output, .name = "output", .keywords =
|
||||||
(notmuch_keyword_t []){ { "sender", OUTPUT_SENDER },
|
(notmuch_keyword_t []){ { "sender", OUTPUT_SENDER },
|
||||||
{ "recipients", OUTPUT_RECIPIENTS },
|
{ "recipients", OUTPUT_RECIPIENTS },
|
||||||
{ "count", OUTPUT_COUNT },
|
{ "count", OUTPUT_COUNT },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_KEYWORD, &ctx->exclude, "exclude", 'x',
|
{ .opt_keyword = &ctx->exclude, .name = "exclude", .keywords =
|
||||||
(notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },
|
(notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },
|
||||||
{ "false", NOTMUCH_EXCLUDE_FALSE },
|
{ "false", NOTMUCH_EXCLUDE_FALSE },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_KEYWORD, &ctx->dedup, "deduplicate", 'D',
|
{ .opt_keyword = &ctx->dedup, .name = "deduplicate", .keywords =
|
||||||
(notmuch_keyword_t []){ { "no", DEDUP_NONE },
|
(notmuch_keyword_t []){ { "no", DEDUP_NONE },
|
||||||
{ "mailbox", DEDUP_MAILBOX },
|
{ "mailbox", DEDUP_MAILBOX },
|
||||||
{ "address", DEDUP_ADDRESS },
|
{ "address", DEDUP_ADDRESS },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_INHERIT, (void *) &common_options, NULL, 0, 0 },
|
{ .opt_inherit = common_options },
|
||||||
{ NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
|
{ .opt_inherit = notmuch_shared_options },
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
opt_index = parse_arguments (argc, argv, options, 1);
|
opt_index = parse_arguments (argc, argv, options, 1);
|
||||||
|
|
|
@ -1093,23 +1093,23 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
notmuch_bool_t single_message;
|
notmuch_bool_t single_message;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_KEYWORD, &format, "format", 'f',
|
{ .opt_keyword = &format, .name = "format", .keywords =
|
||||||
(notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
|
(notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
|
||||||
{ "text", NOTMUCH_FORMAT_TEXT },
|
{ "text", NOTMUCH_FORMAT_TEXT },
|
||||||
{ "sexp", NOTMUCH_FORMAT_SEXP },
|
{ "sexp", NOTMUCH_FORMAT_SEXP },
|
||||||
{ "mbox", NOTMUCH_FORMAT_MBOX },
|
{ "mbox", NOTMUCH_FORMAT_MBOX },
|
||||||
{ "raw", NOTMUCH_FORMAT_RAW },
|
{ "raw", NOTMUCH_FORMAT_RAW },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_INT, ¬much_format_version, "format-version", 0, 0 },
|
{ .opt_int = ¬much_format_version, .name = "format-version" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &exclude, "exclude", 'x', 0 },
|
{ .opt_bool = &exclude, .name = "exclude" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &entire_thread, "entire-thread", 't', 0 },
|
{ .opt_bool = &entire_thread, .name = "entire-thread" },
|
||||||
{ NOTMUCH_OPT_INT, ¶ms.part, "part", 'p', 0 },
|
{ .opt_int = ¶ms.part, .name = "part" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 },
|
{ .opt_bool = ¶ms.crypto.decrypt, .name = "decrypt" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.verify, "verify", 'v', 0 },
|
{ .opt_bool = ¶ms.crypto.verify, .name = "verify" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, ¶ms.output_body, "body", 'b', 0 },
|
{ .opt_bool = ¶ms.output_body, .name = "body" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, ¶ms.include_html, "include-html", 0, 0 },
|
{ .opt_bool = ¶ms.include_html, .name = "include-html" },
|
||||||
{ NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
|
{ .opt_inherit = notmuch_shared_options },
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
opt_index = parse_arguments (argc, argv, options, 1);
|
opt_index = parse_arguments (argc, argv, options, 1);
|
||||||
|
|
|
@ -197,7 +197,7 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
notmuch_bool_t batch = FALSE;
|
notmuch_bool_t batch = FALSE;
|
||||||
notmuch_bool_t remove_all = FALSE;
|
notmuch_bool_t remove_all = FALSE;
|
||||||
FILE *input = stdin;
|
FILE *input = stdin;
|
||||||
char *input_file_name = NULL;
|
const char *input_file_name = NULL;
|
||||||
int opt_index;
|
int opt_index;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -209,11 +209,11 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
sigaction (SIGINT, &action, NULL);
|
sigaction (SIGINT, &action, NULL);
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &batch, "batch", 0, 0 },
|
{ .opt_bool = &batch, .name = "batch" },
|
||||||
{ NOTMUCH_OPT_STRING, &input_file_name, "input", 'i', 0 },
|
{ .opt_string = &input_file_name, .name = "input" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &remove_all, "remove-all", 0, 0 },
|
{ .opt_bool = &remove_all, .name = "remove-all" },
|
||||||
{ NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
|
{ .opt_inherit = notmuch_shared_options },
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
opt_index = parse_arguments (argc, argv, options, 1);
|
opt_index = parse_arguments (argc, argv, options, 1);
|
||||||
|
|
22
notmuch.c
22
notmuch.c
|
@ -47,13 +47,13 @@ static int
|
||||||
_help_for (const char *topic);
|
_help_for (const char *topic);
|
||||||
|
|
||||||
static notmuch_bool_t print_version = FALSE, print_help = FALSE;
|
static notmuch_bool_t print_version = FALSE, print_help = FALSE;
|
||||||
char *notmuch_requested_db_uuid = NULL;
|
const char *notmuch_requested_db_uuid = NULL;
|
||||||
|
|
||||||
const notmuch_opt_desc_t notmuch_shared_options [] = {
|
const notmuch_opt_desc_t notmuch_shared_options [] = {
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 },
|
{ .opt_bool = &print_version, .name = "version" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 },
|
{ .opt_bool = &print_help, .name = "help" },
|
||||||
{ NOTMUCH_OPT_STRING, ¬much_requested_db_uuid, "uuid", 'u', 0 },
|
{ .opt_string = ¬much_requested_db_uuid, .name = "uuid" },
|
||||||
{0, 0, 0, 0, 0}
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* any subcommand wanting to support these options should call
|
/* any subcommand wanting to support these options should call
|
||||||
|
@ -82,8 +82,8 @@ int notmuch_minimal_options (const char *subcommand_name,
|
||||||
int opt_index;
|
int opt_index;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
|
{ .opt_inherit = notmuch_shared_options },
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
opt_index = parse_arguments (argc, argv, options, 1);
|
opt_index = parse_arguments (argc, argv, options, 1);
|
||||||
|
@ -405,15 +405,15 @@ main (int argc, char *argv[])
|
||||||
char *talloc_report;
|
char *talloc_report;
|
||||||
const char *command_name = NULL;
|
const char *command_name = NULL;
|
||||||
command_t *command;
|
command_t *command;
|
||||||
char *config_file_name = NULL;
|
const char *config_file_name = NULL;
|
||||||
notmuch_config_t *config = NULL;
|
notmuch_config_t *config = NULL;
|
||||||
int opt_index;
|
int opt_index;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_STRING, &config_file_name, "config", 'c', 0 },
|
{ .opt_string = &config_file_name, .name = "config" },
|
||||||
{ NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
|
{ .opt_inherit = notmuch_shared_options },
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
talloc_enable_null_tracking ();
|
talloc_enable_null_tracking ();
|
||||||
|
|
|
@ -9,25 +9,26 @@ int main(int argc, char **argv){
|
||||||
int kw_val=0;
|
int kw_val=0;
|
||||||
int fl_val=0;
|
int fl_val=0;
|
||||||
int int_val=0;
|
int int_val=0;
|
||||||
char *pos_arg1=NULL;
|
const char *pos_arg1=NULL;
|
||||||
char *pos_arg2=NULL;
|
const char *pos_arg2=NULL;
|
||||||
char *string_val=NULL;
|
const char *string_val=NULL;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_KEYWORD, &kw_val, "keyword", 'k',
|
{ .opt_keyword = &kw_val, .name = "keyword", .keywords =
|
||||||
(notmuch_keyword_t []){ { "one", 1 },
|
(notmuch_keyword_t []){ { "one", 1 },
|
||||||
{ "two", 2 },
|
{ "two", 2 },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_KEYWORD_FLAGS, &fl_val, "flag", 'f',
|
{ .opt_flags = &fl_val, .name = "flag", .keywords =
|
||||||
(notmuch_keyword_t []){ { "one", 1 << 0},
|
(notmuch_keyword_t []){ { "one", 1 << 0},
|
||||||
{ "two", 1 << 1 },
|
{ "two", 1 << 1 },
|
||||||
{ "three", 1 << 2 },
|
{ "three", 1 << 2 },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_INT, &int_val, "int", 'i', 0},
|
{ .opt_int = &int_val, .name = "int" },
|
||||||
{ NOTMUCH_OPT_STRING, &string_val, "string", 's', 0},
|
{ .opt_string = &string_val, .name = "string" },
|
||||||
{ NOTMUCH_OPT_POSITION, &pos_arg1, 0,0, 0},
|
{ .opt_position = &pos_arg1 },
|
||||||
{ NOTMUCH_OPT_POSITION, &pos_arg2, 0,0, 0},
|
{ .opt_position = &pos_arg2 },
|
||||||
{ 0, 0, 0, 0, 0 } };
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
opt_index = parse_arguments(argc, argv, options, 1);
|
opt_index = parse_arguments(argc, argv, options, 1);
|
||||||
|
|
||||||
|
|
|
@ -44,17 +44,17 @@ int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
enum direction dir = DECODE;
|
int dir = DECODE;
|
||||||
int omit_newline = FALSE;
|
int omit_newline = FALSE;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_KEYWORD, &dir, "direction", 'd',
|
{ .opt_keyword = &dir, .name = "direction", .keywords =
|
||||||
(notmuch_keyword_t []){ { "encode", ENCODE },
|
(notmuch_keyword_t []){ { "encode", ENCODE },
|
||||||
{ "decode", DECODE },
|
{ "decode", DECODE },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &omit_newline, "omit-newline", 'n', 0 },
|
{ .opt_bool = &omit_newline, .name = "omit-newline" },
|
||||||
{ NOTMUCH_OPT_BOOLEAN, &inplace, "in-place", 'i', 0 },
|
{ .opt_bool = &inplace, .name = "in-place" },
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
int opt_index = parse_arguments (argc, argv, options, 1);
|
int opt_index = parse_arguments (argc, argv, options, 1);
|
||||||
|
|
|
@ -116,10 +116,10 @@ random_utf8_string (void *ctx, size_t char_count)
|
||||||
|
|
||||||
/* stubs since we cannot link with notmuch.o */
|
/* stubs since we cannot link with notmuch.o */
|
||||||
const notmuch_opt_desc_t notmuch_shared_options[] = {
|
const notmuch_opt_desc_t notmuch_shared_options[] = {
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
char *notmuch_requested_db_uuid = NULL;
|
const char *notmuch_requested_db_uuid = NULL;
|
||||||
|
|
||||||
void
|
void
|
||||||
notmuch_process_shared_options (unused (const char *dummy))
|
notmuch_process_shared_options (unused (const char *dummy))
|
||||||
|
@ -140,7 +140,7 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
void *ctx = talloc_new (NULL);
|
void *ctx = talloc_new (NULL);
|
||||||
|
|
||||||
char *config_path = NULL;
|
const char *config_path = NULL;
|
||||||
notmuch_config_t *config;
|
notmuch_config_t *config;
|
||||||
notmuch_database_t *notmuch;
|
notmuch_database_t *notmuch;
|
||||||
|
|
||||||
|
@ -155,13 +155,13 @@ main (int argc, char **argv)
|
||||||
int seed = 734569;
|
int seed = 734569;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ NOTMUCH_OPT_STRING, &config_path, "config-path", 'c', 0 },
|
{ .opt_string = &config_path, .name = "config-path" },
|
||||||
{ NOTMUCH_OPT_INT, &num_messages, "num-messages", 'n', 0 },
|
{ .opt_int = &num_messages, .name = "num-messages" },
|
||||||
{ NOTMUCH_OPT_INT, &max_tags, "max-tags", 'm', 0 },
|
{ .opt_int = &max_tags, .name = "max-tags" },
|
||||||
{ NOTMUCH_OPT_INT, &message_id_len, "message-id-len", 'M', 0 },
|
{ .opt_int = &message_id_len, .name = "message-id-len" },
|
||||||
{ NOTMUCH_OPT_INT, &tag_len, "tag-len", 't', 0 },
|
{ .opt_int = &tag_len, .name = "tag-len" },
|
||||||
{ NOTMUCH_OPT_INT, &seed, "seed", 's', 0 },
|
{ .opt_int = &seed, .name = "seed" },
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
int opt_index = parse_arguments (argc, argv, options, 1);
|
int opt_index = parse_arguments (argc, argv, options, 1);
|
||||||
|
|
Loading…
Reference in a new issue