diff options
Diffstat (limited to 'lib/client.lisp')
-rw-r--r-- | lib/client.lisp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/client.lisp b/lib/client.lisp index 8d40fd5..db19bda 100644 --- a/lib/client.lisp +++ b/lib/client.lisp @@ -45,12 +45,18 @@ not in the local cache, try to fetch from configured server." (defmacro when-oneliner ((var name-or-id) &body body) "Finds the oneliner with name-or-id and binds it to var before running the body. If such a oneliner can be found." - (assert (symbolp var)) (let ((nvar (gensym))) `(let ((,nvar ,name-or-id)) (a:when-let (,var (the-oneliner ,nvar)) ,@body)))) +(defmacro when-draft ((var name) &body body) + "Like when-oneliner but restricts itself to local drafts." + (let ((nvar (gensym))) + `(let ((,nvar ,name)) + (a:when-let (,var (fetch-draft ,nvar)) + ,@body)))) + (defun newest-oneliners (&optional limit) (let ((response (if limit @@ -76,10 +82,12 @@ running the body. If such a oneliner can be found." (defvar *ol-output-timeout* 1) -(defun run-item (ident args &key force-clip (timeout nil timeout-p)) - (when-oneliner (ol ident) - (let ((*ol-output-timeout* (if timeout-p timeout *ol-output-timeout*))) - (bind-vars-and-run-oneliner ol args force-clip)))) +(defun run-item (ident args &key force-clip (timeout nil timeout-p) draftp) + "Runs a oneliner identified by IDENT (if available) with arguments ARGS." + (let ((ol (if draftp (fetch-draft ident) (the-oneliner ident)))) + (when ol + (let ((*ol-output-timeout* (if timeout-p timeout *ol-output-timeout*))) + (bind-vars-and-run-oneliner ol args force-clip))))) (defun bind-vars-and-run-oneliner (ol args &optional force-clip) (let* ((oneliner (oneliner-oneliner ol)) |