iens

Manager of links to read
git clone https://git.instinctive.eu/iens.git
Log | Files | Refs | README | LICENSE

commit b7887c183a65726b18b237e79705537ed8576b8c
parent 4e8823ac39071a9cea21e806bb52f48c928f648e
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date:   Sun, 31 Dec 2023 13:05:42 +0000

Add `list-tagged` command
Diffstat:
Msrc/iens.scm | 17+++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/iens.scm b/src/iens.scm @@ -302,6 +302,8 @@ (sql db "INSERT INTO entry(url, notes, ctime, mtime) VALUES (?, ?, ?, ?);")) (define auto-tag-stmt (sql db "INSERT INTO tagrel SELECT ?,id FROM tag WHERE auto = 1;")) +(define list-tagged-stmt + (sql db "SELECT * FROM (SELECT id,url,notes FROM entry WHERE id IN (SELECT url_id FROM tagrel WHERE tag_id IN (SELECT id FROM tag WHERE name=?)) ORDER BY id DESC LIMIT ?) ORDER BY id ASC;")) (define list-untagged-stmt (sql db "SELECT id,url,notes FROM entry WHERE id NOT IN (SELECT url_id FROM tagrel);")) (define select-entry-stmt @@ -402,6 +404,17 @@ select-entry-stmt entry-id)) +(defcmd (list-tagged tag-name . args) + "tag-name [limit]" "Display entries with the given tag" + (query (for-each-row print-listed-entry-row) + list-tagged-stmt + tag-name + (if (null? args) 10 (car args)))) + +(defcmd (list-untagged) + "" "Display entries without any tag" + (query (for-each-row print-listed-entry-row) list-untagged-stmt)) + (defcmd (print-entry . args) "[entry-id]" "Display an entry" (if (null? args) @@ -411,10 +424,6 @@ (print-entry* (car todo)) (loop (cdr todo)))))) -(defcmd (list-untagged) - "" "Display entries without any tag" - (query (for-each-row print-listed-entry-row) list-untagged-stmt)) - (defcmd (set-entry entry-id) "entry-id" "Set current entry" (assert (integer? entry-id))