Add tags command
This commit is contained in:
parent
acc01decbe
commit
209281dcd9
2 changed files with 23 additions and 0 deletions
|
@ -128,3 +128,17 @@ remove all tags from bookmark."
|
|||
|
||||
Print the version number and exit."
|
||||
(format t "clark version ~A~%" version))
|
||||
|
||||
(defcommand tags (&optional (num 0))
|
||||
"List a number of or all tags."
|
||||
"Usage: clark tags [<num>]
|
||||
|
||||
Print a list of tags and the number of bookmarks tagged with it
|
||||
ordered by that number. If NUM is given, only print the first NUM
|
||||
tags."
|
||||
(let ((num (if (integerp num) num (parse-integer num)))
|
||||
(counter 1))
|
||||
(dolist (tag (tag-list))
|
||||
(format t "~30A~10D~%" (car tag) (cadr tag))
|
||||
(if (> (incf counter) num 0)
|
||||
(return)))))
|
||||
|
|
|
@ -141,3 +141,12 @@
|
|||
(execute-to-list
|
||||
*db* (sql select "url"
|
||||
from "bookmark"))))
|
||||
|
||||
(defun tag-list ()
|
||||
"Get a list of all tags stored."
|
||||
(execute-to-list
|
||||
*db* (sql select "name, COUNT(bookmark_id)"
|
||||
from "tag"
|
||||
join "bookmark_tag" on ("tag_id = tag.ROWID")
|
||||
group by "tag.ROWID"
|
||||
order by "COUNT(bookmark_id)" desc)))
|
||||
|
|
Loading…
Reference in a new issue