diff options
author | Lukas Fleischer <lfleischer@calcurse.org> | 2016-01-11 22:26:46 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2016-01-13 17:39:44 +0100 |
commit | 7f8c62bf57b85234c248316505a503602792839a (patch) | |
tree | ef8ff6e778840192ee7cfb6c06579602ed6942cb /src/args.c | |
parent | dd85a7374675c3f91e215c2e318b2c5045a01f53 (diff) | |
download | calcurse-7f8c62bf57b85234c248316505a503602792839a.zip |
Add an option to filter by object hash
Implement a new --filter-hash option to filter by object identifiers.
Each object having an identifier that has the specified pattern as a
prefix is matched. Patterns starting with an exclamation mark (!) are
interpreted as negative patterns.
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/args.c')
-rw-r--r-- | src/args.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -47,6 +47,7 @@ /* Long options */ enum { OPT_FILTER_TYPE = 1000, + OPT_FILTER_HASH, OPT_FILTER_PATTERN, OPT_FILTER_START_FROM, OPT_FILTER_START_TO, @@ -442,7 +443,7 @@ int parse_args(int argc, char **argv) int range = -1; int limit = INT_MAX; /* Filters */ - struct item_filter filter = { 0, NULL, -1, -1, -1, -1, 0, 0, 0 }; + struct item_filter filter = { 0, NULL, NULL, -1, -1, -1, -1, 0, 0, 0 }; /* Format strings */ const char *fmt_apt = " - %S -> %E\n\t%m\n"; const char *fmt_rapt = " - %S -> %E\n\t%m\n"; @@ -481,6 +482,7 @@ int parse_args(int argc, char **argv) {"query", optional_argument, NULL, 'Q'}, {"filter-type", required_argument, NULL, OPT_FILTER_TYPE}, + {"filter-hash", required_argument, NULL, OPT_FILTER_HASH}, {"filter-pattern", required_argument, NULL, OPT_FILTER_PATTERN}, {"filter-start-from", required_argument, NULL, OPT_FILTER_START_FROM}, {"filter-start-to", required_argument, NULL, OPT_FILTER_START_TO}, @@ -604,6 +606,9 @@ int parse_args(int argc, char **argv) EXIT_IF(filter.type_mask == 0, _("invalid filter mask")); break; + case OPT_FILTER_HASH: + filter.hash = mem_strdup(optarg); + break; case 'S': case OPT_FILTER_PATTERN: EXIT_IF(filter.regex, |