Implement filter mode
Add a new -F mode that is identical to -G but writes the result back to the calcurse data files instead of stdout. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
7f8c62bf57
commit
6d9129764b
12
src/args.c
12
src/args.c
@ -436,7 +436,7 @@ cleanup:
|
|||||||
int parse_args(int argc, char **argv)
|
int parse_args(int argc, char **argv)
|
||||||
{
|
{
|
||||||
/* Command-line flags */
|
/* Command-line flags */
|
||||||
int grep = 0, query = 0, next = 0;
|
int grep = 0, grep_filter = 0, query = 0, next = 0;
|
||||||
int status = 0, gc = 0, import = 0, export = 0;
|
int status = 0, gc = 0, import = 0, export = 0;
|
||||||
/* Query ranges */
|
/* Query ranges */
|
||||||
time_t from = -1, to = -1;
|
time_t from = -1, to = -1;
|
||||||
@ -459,13 +459,14 @@ int parse_args(int argc, char **argv)
|
|||||||
int ch;
|
int ch;
|
||||||
regex_t reg;
|
regex_t reg;
|
||||||
|
|
||||||
static const char *optstr = "gGhvnNax::t::d:c:r::s::S:D:i:l:Q";
|
static const char *optstr = "FgGhvnNax::t::d:c:r::s::S:D:i:l:Q";
|
||||||
|
|
||||||
struct option longopts[] = {
|
struct option longopts[] = {
|
||||||
{"appointment", no_argument, NULL, 'a'},
|
{"appointment", no_argument, NULL, 'a'},
|
||||||
{"calendar", required_argument, NULL, 'c'},
|
{"calendar", required_argument, NULL, 'c'},
|
||||||
{"day", required_argument, NULL, 'd'},
|
{"day", required_argument, NULL, 'd'},
|
||||||
{"directory", required_argument, NULL, 'D'},
|
{"directory", required_argument, NULL, 'D'},
|
||||||
|
{"filter", no_argument, NULL, 'F'},
|
||||||
{"gc", no_argument, NULL, 'g'},
|
{"gc", no_argument, NULL, 'g'},
|
||||||
{"grep", no_argument, NULL, 'G'},
|
{"grep", no_argument, NULL, 'G'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
@ -534,6 +535,9 @@ int parse_args(int argc, char **argv)
|
|||||||
case 'D':
|
case 'D':
|
||||||
datadir = optarg;
|
datadir = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'F':
|
||||||
|
grep_filter = grep = 1;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
help_arg();
|
help_arg();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -754,8 +758,8 @@ int parse_args(int argc, char **argv)
|
|||||||
vars_init();
|
vars_init();
|
||||||
config_load(); /* To get output date format. */
|
config_load(); /* To get output date format. */
|
||||||
io_load_data(&filter);
|
io_load_data(&filter);
|
||||||
io_save_todo(NULL);
|
io_save_todo(grep_filter ? path_todo : NULL);
|
||||||
io_save_apts(NULL);
|
io_save_apts(grep_filter ? path_apts : NULL);
|
||||||
} else if (query) {
|
} else if (query) {
|
||||||
io_check_file(path_apts);
|
io_check_file(path_apts);
|
||||||
io_check_file(path_todo);
|
io_check_file(path_todo);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user