about summary refs log tree commit diff
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
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.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;
> 2022-06-08Add Maiden, Mother, CroneJune McEnroe 2022-06-05FIRST SHOW IN 2.5 YEARS BABEY!!!June McEnroe 2022-06-03Set line number on File linesJune McEnroe 2022-06-03Stop polling stdin after EOFJune McEnroe 2022-06-02Set TABSIZE=4June McEnroe 2022-06-02Do basic match highlightingJune McEnroe 2022-06-02Clean up parsing a littleJune McEnroe 2022-06-02Don't duplicate path stringJune McEnroe 2022-06-02Use stderr instead of /dev/tty, realloc buffer if lines too longJune McEnroe 2022-06-02Add initial working version of qfJune McEnroe 2022-05-29Set prompt for okshJune McEnroess='nohover-highlight'> 2022-07-26Update Care with time-to-ID and piercingsJune McEnroe 2022-07-26Add -w to upJune McEnroe 2022-07-13Set push.autoSetupRemoteJune McEnroe 2022-07-08Remove TOURJune McEnroe There is not that much distinct stuff here anymore. 2022-07-03Add The Bone Shard EmperorJune McEnroe Suffers a little bit from middle book but I really enjoyed it. Read it faster than the first one too, despite its length. 2022-06-25Bump xterm font size to 12June McEnroe 2022-06-10Handle subshells (and functions) inside substitutionsJune McEnroe 2022-06-10Switch to jorts Install scriptJune McEnroe 2022-06-08Indicate if still reading or no resultsJune McEnroe 2022-06-08Add Maiden, Mother, CroneJune McEnroe Mixed bag like most collections of short stories. Some of them are pretty good. The author of the worst written story also has the worst written bio. 2022-06-05FIRST SHOW IN 2.5 YEARS BABEY!!!June McEnroe 2022-06-03Set line number on File linesJune McEnroe 2022-06-03Stop polling stdin after EOFJune McEnroe 2022-06-02Set TABSIZE=4June McEnroe Absolutely indiscriminately. 2022-06-02Do basic match highlightingJune McEnroe 2022-06-02Clean up parsing a littleJune McEnroe 2022-06-02Don't duplicate path stringJune McEnroe 2022-06-02Use stderr instead of /dev/tty, realloc buffer if lines too longJune McEnroe For some reason I haven't been able to figure out, trying to poll /dev/tty returns POLLNVAL (and this was using 100% CPU looping), but using stderr instead works fine. 2022-06-02Add initial working version of qfJune McEnroe 2022-05-29Set prompt for okshJune McEnroe