From e00748a655193fdfc50e543517568a10ac68063d Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Sat, 9 May 2020 14:09:17 +0200 Subject: [PATCH] Operators for stickers are something that can be parsed by the shell... --- doc/lkt.1 | 5 +++-- src/main/lkt.c | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/doc/lkt.1 b/doc/lkt.1 index 911e8436..a45acc98 100644 --- a/doc/lkt.1 +++ b/doc/lkt.1 @@ -142,8 +142,9 @@ List the stickers of an object \fIuri\fP. The object \fItype\fP can be \fIkara\fP or \fIplt\fP. A condition can be defined on the value of the sticker with an operator -\fIop\fP and an integer value \fIvalue\fP. Supported operators are \fI<\fP, -\fI=\fP and \fI>\fP. Operations are not strict. +\fIop\fP and an integer value \fIvalue\fP. Supported operators are \fIl\fP +for 'less than', \fIe\fP for 'equal to' and \fIg\fP for 'greater than'. +Operations are not strict. .TP \fBsticker set\fP <type> <uri> <name> <value> Set the value of a sticker \fIname\fP to \fIvalue\fP for the object with the diff --git a/src/main/lkt.c b/src/main/lkt.c index bb7613fb..06050b75 100644 --- a/src/main/lkt.c +++ b/src/main/lkt.c @@ -703,9 +703,13 @@ stickers_get__(struct lkt_cmd_args *args) else if (args->argc == 3) write_socket(sock = lkt_connect(), "sticker get %s %s %s\n", args->argv[0], args->argv[1], args->argv[2]); - else if (args->argc == 5) + else if (args->argc == 5) { + const char *op = args->argv[3]; + op = op[0] == 'e' ? "=" : op[0] == 'l' ? "<" : op[0] == 'g' ? ">" : NULL; + fail_if(!op, "Invalid argument"); write_socket(sock = lkt_connect(), "sticker get %s %s %s %s %s\n", args->argv[0], - args->argv[1], args->argv[2], args->argv[3], args->argv[4]); + args->argv[1], args->argv[2], op, args->argv[4]); + } else fail("Invalid argument"); -- GitLab