summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2018-12-06 10:35:26 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2019-01-07 16:58:08 +0100
commitb9f23e134a905b13aaa86935929a510ff75f75ef (patch)
tree1e0e05b0ca7f2a603eaa64498961d0d866fe2b0e /src
parent42abbf53463cbbdcd319063fcbfb91cf6ed5bdc5 (diff)
downloadcalcurse-b9f23e134a905b13aaa86935929a510ff75f75ef.tar.gz
calcurse-b9f23e134a905b13aaa86935929a510ff75f75ef.zip
Purge option glorified
The invert filter option is automatically set for -P (and cannot be used on the command line). The intention is that the grep option (-G) is used to find the items that should be removed. To remove them, the same command is run with -P instead of -G. In general, purge will remove matching items (silently). Backward compatibility for option -F (no invert filter). Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src')
-rw-r--r--src/args.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/args.c b/src/args.c
index d2e4860..9986886 100644
--- a/src/args.c
+++ b/src/args.c
@@ -401,7 +401,7 @@ cleanup:
int parse_args(int argc, char **argv)
{
/* Command-line flags - NOTE that read_only is global */
- int grep = 0, purge = 0, query = 0, next = 0;
+ int grep = 0, grep_filter = 0, purge = 0, query = 0, next = 0;
int status = 0, gc = 0, import = 0, export = 0, daemon = 0;
/* Command line invocation */
int filter_opt = 0, format_opt = 0, query_range = 0, cmd_line = 0;
@@ -545,7 +545,7 @@ int parse_args(int argc, char **argv)
case 'D':
break;
case 'F':
- purge = grep = 1;
+ grep_filter = grep = 1;
break;
case 'h':
help_arg();
@@ -567,6 +567,7 @@ int parse_args(int argc, char **argv)
next = 1;
break;
case 'P':
+ filter.invert = 1;
purge = grep = 1;
break;
case 'r':
@@ -865,7 +866,9 @@ int parse_args(int argc, char **argv)
optind < argc ||
(filter_opt && !(grep + query + export)) ||
(format_opt && !(grep + query + dump_imported)) ||
- (query_range && !query)) {
+ (query_range && !query) ||
+ (purge && !filter.invert)
+ ) {
ERROR_MSG(_("invalid argument combination"));
usage();
usage_try();
@@ -895,7 +898,7 @@ int parse_args(int argc, char **argv)
io_check_file(path_todo);
io_check_file(path_conf);
io_load_data(&filter, FORCE);
- if (purge) {
+ if (purge || grep_filter) {
io_save_todo(path_todo);
io_save_apts(path_apts);
} else {