summary refs log tree commit diff
path: root/litterbox.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-12-30 00:48:21 -0500
committerJune McEnroe <june@causal.agency>2019-12-30 00:48:21 -0500
commited174b12f7a2f1bfca8c7b73fb6fd6a2f9ddf8f7 (patch)
tree0edab3c605321745dbf3e4c13244f80c885d098e /litterbox.c
parentAdd prospective scoop manual page (diff)
downloadlitterbox-ed174b12f7a2f1bfca8c7b73fb6fd6a2f9ddf8f7.tar.gz
litterbox-ed174b12f7a2f1bfca8c7b73fb6fd6a2f9ddf8f7.zip
Add limit option for litterbox's search query interface
Diffstat (limited to '')
-rw-r--r--litterbox.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/litterbox.c b/litterbox.c
index f02948e..3ede752 100644
--- a/litterbox.c
+++ b/litterbox.c
@@ -105,6 +105,7 @@ static enum {
 	Private,
 	Public,
 } searchQuery;
+static int searchLimit = 10;
 
 static char *self;
 static char *network;
@@ -224,12 +225,13 @@ static void querySearch(struct Message *msg) {
 				AND coalesce(contexts.query = :query, true)
 				AND search MATCH :search
 			ORDER BY events.time DESC, events.event DESC
-			LIMIT 10
+			LIMIT :limit
 		)
 		SELECT * FROM results ORDER BY context, time;
 	);
 	dbPersist(&stmt, sql);
 	dbBindText(stmt, ":bold", "\2");
+	dbBindInt(stmt, ":limit", searchLimit);
 
 	dbBindText(stmt, ":network", network);
 	if (searchQuery == Public) {
@@ -633,7 +635,7 @@ int main(int argc, char *argv[]) {
 	const char *pass = NULL;
 
 	int opt;
-	while (0 < (opt = getopt(argc, argv, "!Qd:h:ij:mn:p:qu:vw:"))) {
+	while (0 < (opt = getopt(argc, argv, "!Qd:h:ij:l:mn:p:qu:vw:"))) {
 		switch (opt) {
 			break; case '!': insecure = true;
 			break; case 'Q': searchQuery = Public;
@@ -641,6 +643,7 @@ int main(int argc, char *argv[]) {
 			break; case 'h': host = optarg;
 			break; case 'i': init = true;
 			break; case 'j': join = optarg;
+			break; case 'l': searchLimit = strtol(optarg, NULL, 0);
 			break; case 'm': migrate = true;
 			break; case 'n': nick = optarg;
 			break; case 'p': port = optarg;