Add remove-tags command
This command removes the given tags (or all if none are specified) from a bookmark's tag list.
This commit is contained in:
parent
6121891396
commit
df47a68535
4 changed files with 29 additions and 4 deletions
|
@ -158,6 +158,11 @@ Replace @var{url}'s tags with @var{tags}. @var{tags} may be omitted,
|
|||
in which case all the tags for @var{url} are removed.
|
||||
@end deffn
|
||||
|
||||
@deffn Command remove-tags URL [TAGS...]
|
||||
Remove @var{tags} from @var{url}'s tag list. If @var{tags} is omitted,
|
||||
remove all tags from @var{url}'s tag list.
|
||||
@end deffn
|
||||
|
||||
@node Miscellaneous, , Management, Usage
|
||||
@section Other things that can be done
|
||||
|
||||
|
|
|
@ -36,5 +36,5 @@ $(install-binaries): install-%: %
|
|||
$(uninstall-binaries): uninstall-%:
|
||||
rm -f "$(DESTDIR)/bin/$*"
|
||||
|
||||
clark: clark.lisp make-image.lisp
|
||||
clark: clark.lisp queries.lisp make-image.lisp
|
||||
$(LISP) --load make-image.lisp
|
||||
|
|
|
@ -285,6 +285,14 @@ Get a random bookmark. If TAG is given limit the result to a bookmark
|
|||
having the tag TAG."
|
||||
(format t "~a~%" (random-item (url-list tag))))
|
||||
|
||||
(defcommand remove-tags (url &rest tags)
|
||||
"Remove given tags from bookmark's tag list."
|
||||
"Usage: clark remove-tags <url> [<tags> ...]
|
||||
|
||||
Remove the given TAGS from URL's tag list. If no tags are given,
|
||||
remove all tags from bookmark."
|
||||
(delete-tags url tags))
|
||||
|
||||
(defcommand version ()
|
||||
"Show version."
|
||||
"Usage: clark version
|
||||
|
|
|
@ -68,10 +68,22 @@
|
|||
(execute-non-query
|
||||
*db* (sql delete from "bookmark" where "url" = ?) url))
|
||||
|
||||
(defun delete-tags (id)
|
||||
(defun delete-tags (id &optional tags)
|
||||
"Clear the tags for bookmark with id ID."
|
||||
(execute-non-query *db* (sql delete from "bookmark_tag"
|
||||
where "bookmark_id" = ?) id))
|
||||
(if tags
|
||||
(map nil
|
||||
(lambda (tag)
|
||||
(execute-non-query
|
||||
*db* (sql delete from "bookmark_tag"
|
||||
where "bookmark_id" = (select "rowid"
|
||||
from "bookmark"
|
||||
where "url" = ?)
|
||||
and "tag_id" in (select "rowid"
|
||||
from "tag"
|
||||
where "name" = ?))
|
||||
id tag)) tags)
|
||||
(execute-non-query *db* (sql delete from "bookmark_tag"
|
||||
where "bookmark_id" = ?) id)))
|
||||
|
||||
(defun get-bookmark-id (url)
|
||||
"Get the id of the bookmark for URL."
|
||||
|
|
Loading…
Reference in a new issue