diff options
author | Tom Willemsen | 2013-03-23 19:24:48 +0100 |
---|---|---|
committer | Tom Willemsen | 2013-03-23 19:25:28 +0100 |
commit | e94a9ac0135542b2cf65cea08c9b54beaa02dc4d (patch) | |
tree | cdfda31865b95e244abf0df358e19433508fff04 /lisp | |
parent | d1eb7d4c379aa480fd25474a189ce53c4374142c (diff) | |
download | clark-e94a9ac0135542b2cf65cea08c9b54beaa02dc4d.tar.gz clark-e94a9ac0135542b2cf65cea08c9b54beaa02dc4d.zip |
Add edit command
Allows one to edit the name and description of a bookmark.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/clark.lisp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lisp/clark.lisp b/lisp/clark.lisp index 1f3ec93..84d839d 100644 --- a/lisp/clark.lisp +++ b/lisp/clark.lisp @@ -182,6 +182,28 @@ omitted or any number of tag names." (insert-bookmark url name description) (add-tags tags)))) +(defcommand edit (:min-args 3) + "Edit a bookmark." + "Usage: clark edit <url> [--name <name>] \\ + [--description <description>] + +Edit the information for URL, specifying which part(s) to edit. Each +option will replace the previous value for that part." + (let ((name-lst (member "--name" args :test #'string=)) + (desc-lst (member "--description" args :test #'string=)) + query qargs) + (when name-lst + (setf query (concatenate 'string query "name = ? ") + qargs (nconc qargs (list (cadr name-lst))))) + (when desc-lst + (setf query (concatenate 'string query (when qargs ", ") + "description = ? ") + qargs (nconc qargs (list (cadr desc-lst))))) + (when qargs + (apply #'execute-non-query *db* + (format nil "UPDATE bookmark SET ~A WHERE url = ?" query) + (append qargs (list (car args))))))) + (defcommand exists (:min-args 1 :max-args 1) "Check if a bookmark exists in the database." "Usage: clark exists <url> |