aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.lisp53
1 files changed, 47 insertions, 6 deletions
diff --git a/src/lib.lisp b/src/lib.lisp
index 858675f..ca1bd81 100644
--- a/src/lib.lisp
+++ b/src/lib.lisp
@@ -93,19 +93,17 @@ the directories that appear in the value of that variable."
(defun prompt (prompt
&key
- (out-stream *standard-output*)
- (in-stream *standard-input*)
(expect (constantly t))
retry-text)
(loop
- with to-prompt = prompt
+ ;with to-prompt = prompt
with should-retry-p = t
while should-retry-p
for line = (progn
- (princ to-prompt out-stream) (force-output out-stream)
- (setf to-prompt (or retry-text prompt))
- (read-line in-stream))
+ ;(princ to-prompt out-stream) (force-output out-stream)
+ ;(setf to-prompt (or retry-text prompt))
+ (linedit:linedit :prompt prompt))
when (funcall expect line)
do (setf should-retry-p nil)
finally (return line)))
@@ -180,6 +178,8 @@ the directories that appear in the value of that variable."
(run-with-shell ol :shell-name (or (get-shell) "bash")))))
+
+
(defun run-item (item-number args &optional force-clip)
(with-cached-result (ol item-number)
(let* ((oneliner (getf ol :oneliner))
@@ -252,6 +252,47 @@ the directories that appear in the value of that variable."
(api:post--oneliner :token (api-token))
(format t "Added~%"))))
+(defun edit-item (n)
+ (ensure-config)
+ (assert (api-token) () "Cannot edit a oneliner without an api token.")
+ (with-cached-result (ol n)
+ (let* ((oneliner
+ (prompt "Oneliner: "
+ :expect 'valid-oneliner-string-p
+ :retry-text "Oneliners must contain at least one command: "))
+ (init-tags
+ (tags-from-oneliner oneliner))
+ (brief
+ (prompt "Brief Description: "
+ :expect 'valid-brief-description-p
+ :retry-text "Too long. Must be <= 72 characters: "))
+ (tags
+ (append init-tags
+ (ppcre:split " +"
+ (prompt (format nil "Tags in addition to ~{~a ~} ?" init-tags)))))
+ (runstyle
+ (string-upcase
+ (prompt "Runstyle (auto or manual): "
+ :expect 'valid-runstyle-p
+ :retry-text "Must be (auto or manual): ")))
+ (explanation
+ (when (y-or-n-p "Provide an explanation?")
+ (string-from-editor))))
+ (api:request-with
+ (:host (host)
+ :body (jonathan:to-json
+ (list :oneliner oneliner
+ :tags tags
+ :brief brief
+ :explanation explanation
+ :runstyle runstyle))
+ :content-type "application/json")
+ (api:patch--oneliner-entry-edit (getf ol :id) :token (api-token))
+ (format t "OK~%")))
+
+
+ ))
+
(defun request-invite-code ()
(ensure-config)
(api:request-with