aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-01-12 08:52:39 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2016-01-13 17:39:44 +0100
commit6d9129764bebb775951c2c8629a291407c25a693 (patch)
treefad883a79e452c4a74be7169e8c5d9803488ac35
parent7f8c62bf57b85234c248316505a503602792839a (diff)
downloadcalcurse-6d9129764bebb775951c2c8629a291407c25a693.tar.gz
calcurse-6d9129764bebb775951c2c8629a291407c25a693.zip
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>
-rw-r--r--src/args.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/args.c b/src/args.c
index c843d69..751a41a 100644
--- a/src/args.c
+++ b/src/args.c
@@ -436,7 +436,7 @@ cleanup:
int parse_args(int argc, char **argv)
{
/* 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;
/* Query ranges */
time_t from = -1, to = -1;
@@ -459,13 +459,14 @@ int parse_args(int argc, char **argv)
int ch;
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[] = {
{"appointment", no_argument, NULL, 'a'},
{"calendar", required_argument, NULL, 'c'},
{"day", required_argument, NULL, 'd'},
{"directory", required_argument, NULL, 'D'},
+ {"filter", no_argument, NULL, 'F'},
{"gc", no_argument, NULL, 'g'},
{"grep", no_argument, NULL, 'G'},
{"help", no_argument, NULL, 'h'},
@@ -534,6 +535,9 @@ int parse_args(int argc, char **argv)
case 'D':
datadir = optarg;
break;
+ case 'F':
+ grep_filter = grep = 1;
+ break;
case 'h':
help_arg();
goto cleanup;
@@ -754,8 +758,8 @@ int parse_args(int argc, char **argv)
vars_init();
config_load(); /* To get output date format. */
io_load_data(&filter);
- io_save_todo(NULL);
- io_save_apts(NULL);
+ io_save_todo(grep_filter ? path_todo : NULL);
+ io_save_apts(grep_filter ? path_apts : NULL);
} else if (query) {
io_check_file(path_apts);
io_check_file(path_todo);