From ed174b12f7a2f1bfca8c7b73fb6fd6a2f9ddf8f7 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Mon, 30 Dec 2019 00:48:21 -0500 Subject: Add limit option for litterbox's search query interface --- litterbox.1 | 11 ++++++++++- litterbox.c | 7 +++++-- 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; -- cgit 1.4.1 >unfollow)
Commit message (Expand)Author
2019-10-28Move entire login flow to state and reorganize itJune McEnroe
2019-10-27Wait for SASL success before sending CAP ENDJune McEnroe
2019-10-27Only increment consumer after successful sendJune McEnroe
2019-10-27Set SO_REUSEADDR on bindsJune McEnroe
2019-10-27Output ring info on SIGINFOJune McEnroe
2019-10-27Improve client/server error messagesJune McEnroe
2019-10-27Add reload cmd to rc scriptJune McEnroe
2019-10-27Reload certificate on SIGUSR1June McEnroe
2019-10-27Drop clients on zero-length readsJune McEnroe
2019-10-27Explicitly tls_handshake new clientsJune McEnroe
2019-10-26Document rationaleJune McEnroe
2019-10-26Handle nick collisionJune McEnroe
2019-10-26Wait for AUTHENTICATE + from serverJune McEnroe
2019-10-26Respond to PING with same parameterJune 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