about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--litterbox.111
-rw-r--r--litterbox.c7
2 files changed, 15 insertions, 3 deletions
diff --git a/litterbox.1 b/litterbox.1
index 3f0446a..6910713 100644
--- a/litterbox.1
+++ b/litterbox.1
@@ -1,4 +1,4 @@
-.Dd December 27, 2019
+.Dd December 30, 2019
 .Dt LITTERBOX 1
 .Os
 .
@@ -12,6 +12,7 @@
 .Op Fl d Ar path
 .Op Fl h Ar host
 .Op Fl j Ar join
+.Op Fl l Ar limit
 .Op Fl n Ar nick
 .Op Fl p Ar port
 .Op Fl u Ar user
@@ -69,6 +70,14 @@ Initialize the database.
 Join the comma-separated list of channels
 .Ar join .
 .
+.It Fl l Ar limit
+Limit the number of results sent by the
+.Fl Q
+or
+.Fl q
+search query interface.
+The default limit is 10.
+.
 .It Fl m
 Migrate the database to the latest version.
 .
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;