summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--scoop.19
-rw-r--r--scoop.c14
2 files changed, 18 insertions, 5 deletions
diff --git a/scoop.1 b/scoop.1
index 823e5ee..a9a40c0 100644
--- a/scoop.1
+++ b/scoop.1
@@ -8,7 +8,7 @@
 .
 .Sh SYNOPSIS
 .Nm
-.Op Fl pqv
+.Op Fl gpqv
 .Op Fl D Ar date
 .Op Fl N Ar network
 .Op Fl T Ar target
@@ -43,7 +43,9 @@ The arguments are as follows:
 Match events which occurred on
 .Ar date ,
 of the format
-.Ar YYYY-MM-DD .
+.Ar YYYY-MM-DD
+or the keyword
+.Cm now .
 .
 .It Fl N Ar network
 Match events from contexts on
@@ -72,6 +74,9 @@ The database must have been initialized by
 The default path is as in
 .Xr litterbox 1 .
 .
+.It Fl g
+Group events by context.
+.
 .It Fl h Ar host
 Match events from users with the hostname
 .Ar host .
diff --git a/scoop.c b/scoop.c
index 5855e70..1f031e2 100644
--- a/scoop.c
+++ b/scoop.c
@@ -29,6 +29,7 @@ static const char *Inner = SQL(
 	SELECT
 		contexts.network,
 		contexts.name AS context,
+		// TODO: Replace with a strftime and option.
 		date(events.time) || 'T' || time(events.time) || 'Z' AS time,
 		events.type,
 		names.nick,
@@ -66,6 +67,11 @@ static const char *Outer = SQL(
 	ORDER BY time, event
 );
 
+static const char *Group = SQL(
+	SELECT * FROM results
+	ORDER BY network, context, time, event
+);
+
 typedef void Format(
 	const char *network, const char *context, const char *time, enum Type type,
 	const char *nick, const char *user, const char *target, const char *message
@@ -176,15 +182,17 @@ int main(int argc, char *argv[]) {
 	const char *target = NULL;
 	const char *search = NULL;
 	int limit = -1;
+	bool group = false;
 
 	int opt;
-	while (0 < (opt = getopt(argc, argv, "D:N:T:c:d:h:l:n:pqst:u:v"))) {
+	while (0 < (opt = getopt(argc, argv, "D:N:T:c:d:gh:l:n:pqst:u:v"))) {
 		switch (opt) {
 			break; case 'D': date = optarg;
 			break; case 'N': network = optarg;
 			break; case 'T': target = optarg;
 			break; case 'c': context = optarg;
 			break; case 'd': path = optarg;
+			break; case 'g': group = true;
 			break; case 'h': host = optarg;
 			break; case 'l': limit = strtol(optarg, NULL, 0);
 			break; case 'n': nick = optarg;
@@ -244,13 +252,13 @@ int main(int argc, char *argv[]) {
 		snprintf(
 			sql, sizeof(sql),
 			"WITH results AS (%s AND %s %s) %s;",
-			Inner, Search, Limit, Outer
+			Inner, Search, Limit, (group ? Group : Outer)
 		);
 	} else {
 		snprintf(
 			sql, sizeof(sql),
 			"WITH results AS (%s %s) %s;",
-			Inner, Limit, Outer
+			Inner, Limit, (group ? Group : Outer)
 		);
 	}
 
3June McEnroe 2021-08-29Update to Linux man-pages 5.13 2062.53Štěpán Němec 2021-08-26Update to NetBSD 9.2 2062.52June McEnroe 2021-08-26Support DESTDIR in install/uninstallJune McEnroe 2021-08-26Add version number generatorJune McEnroe 2021-08-22Add ISC license headerJune McEnroe 2021-08-22Update to Linux man-pages 5.12Štěpán Němec 2021-06-21Add manuals for macOS 11.3June McEnroe 2021-05-08Update to OpenBSD 6.9June McEnroe 2021-04-26Update to Linux man-pages 5.11June McEnroe 2021-04-26Update to FreeBSD 13.0June McEnroe 2021-01-27Completely rewrite how manuals are fetched and installedJune McEnroe Also add section 6 manuals from NetBSD and OpenBSD! 2020-12-14Update to man-pages-posix 2017-aJune McEnroe 2020-12-14Update to OpenBSD 6.8June McEnroe 2020-12-14Update to NetBSD 9.1June McEnroe 2020-12-14Update to man-pages 5.09June McEnroe 2020-12-14Update to FreeBSD 12.2June McEnroe 2020-06-08Update to OpenBSD 6.7June McEnroe 2020-05-04Add hack for macOS to search extra man sectionsJune McEnroe 2020-05-04Don't clear MANSECTJune McEnroe