summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-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)
 		);
 	}
 
meterJune McEnroe 2019-10-26Add undocumented flag to disable verificationJune McEnroe 2019-10-26Do not require RPL_ISUPPORT for stateReadyJune McEnroe 2019-10-26Implement graceful shutdownJune McEnroe 2019-10-26Require PASS before USERJune McEnroe 2019-10-26Track channel topicsJune McEnroe 2019-10-26Set AWAY when no clients are connectedJune McEnroe 2019-10-26Add flags to request TOPIC and NAMES on client connectJune McEnroe 2019-10-26OopsJune McEnroe 2019-10-26Disconnect client on unknown commandJune McEnroe 2019-10-26Allow reading sensitive information from filesJune McEnroe 2019-10-26Add rc scriptJune McEnroe 2019-10-25Add install and uninstall targetsJune McEnroe 2019-10-25Expand documentationJune McEnroe 2019-10-25Add AGPLv3 notice on client registrationJune McEnroe 2019-10-25Rename project pounceJune McEnroe