about summary refs log tree commit diff
path: root/scoop.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-04-28 18:02:20 -0400
committerJune McEnroe <june@causal.agency>2021-04-28 18:02:20 -0400
commit3827d74a9e89ff22654b4c0fb895fe2d33fc9209 (patch)
tree064f625e25ebe6b7897cc9a969f65db932b256ad /scoop.c
parentInterpret -D, -a, -b as local time with -L (diff)
downloadlitterbox-3827d74a9e89ff22654b4c0fb895fe2d33fc9209.tar.gz
litterbox-3827d74a9e89ff22654b4c0fb895fe2d33fc9209.zip
Match multiple types with -t
Diffstat (limited to '')
-rw-r--r--scoop.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/scoop.c b/scoop.c
index 6c2957b..f1c0ed2 100644
--- a/scoop.c
+++ b/scoop.c
@@ -344,6 +344,14 @@ static enum Type parseType(const char *input) {
 	errx(EX_USAGE, "no such type %s", input);
 }
 
+static int parseTypes(char *list) {
+	int mask = 0;
+	while (list) {
+		mask |= 1 << parseType(strsep(&list, ","));
+	}
+	return mask;
+}
+
 int main(int argc, char *argv[]) {
 	bool tty = isatty(STDOUT_FILENO);
 
@@ -466,8 +474,8 @@ int main(int argc, char *argv[]) {
 				sort = true;
 			}
 			break; case 't': {
-				append(where, SQL(AND events.type = :type));
-				binds[n++] = Bind(":type", NULL, parseType(optarg));
+				append(where, SQL(AND (1 << events.type) & :types));
+				binds[n++] = Bind(":types", NULL, parseTypes(optarg));
 			}
 			break; case 'u': {
 				append(where, SQL(AND names.user = :user));