aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-08-06 09:09:42 -0500
committerColin Okay <colin@cicadas.surf>2022-08-06 09:09:42 -0500
commitb46a00f1856947d66c8f74b9f24f7574133a1663 (patch)
treeee1bdf510b7bbeae9270702f7fd75f2d093b8782 /lib
parent575695b5f1f204aa670b996e791822f36f47ee1d (diff)
[fix] saving local state after command finishes
Diffstat (limited to 'lib')
-rw-r--r--lib/client.lisp3
-rw-r--r--lib/oneliner.lisp6
-rw-r--r--lib/state.lisp36
3 files changed, 26 insertions, 19 deletions
diff --git a/lib/client.lisp b/lib/client.lisp
index e3f304e..13bf2fe 100644
--- a/lib/client.lisp
+++ b/lib/client.lisp
@@ -86,7 +86,8 @@ running the body. If such a oneliner can be found."
(when *drafts*
(format t (concatenate 'string "~%~" (prin1-to-string *term-width*) "< ~;DRAFTS~; ~>~%"))
(dolist (draft *drafts*)
- (print-oneliner-result-for-user (cdr draft)))))
+ (format t "Draft Name: ~a~%" (first draft))
+ (print-oneliner-result-for-user (rest draft)))))
;;; RUNNING ONELINERS
diff --git a/lib/oneliner.lisp b/lib/oneliner.lisp
index 8386fa9..3935a0e 100644
--- a/lib/oneliner.lisp
+++ b/lib/oneliner.lisp
@@ -87,8 +87,10 @@
(equalp "manual" (oneliner-runstyle ol))))
(format t tags-line-format-string
(format nil "tags: ~{~a~^ ~}" (oneliner-tags ol))
- (oneliner-createdby ol)
- (datestring-of-universal-time (oneliner-createdat ol)))
+ (or (oneliner-createdby ol) " ")
+ (if (oneliner-createdat ol)
+ (datestring-of-universal-time (oneliner-createdat ol))
+ " "))
(loop
for x from 0 to (length (oneliner-brief ol)) by *term-width*
do (format t "~a~%"
diff --git a/lib/state.lisp b/lib/state.lisp
index 49cd5d8..e690f37 100644
--- a/lib/state.lisp
+++ b/lib/state.lisp
@@ -169,19 +169,23 @@ sets the api's *host* variable. If BODY produces no errors, the "
`(let* ((*config* (ensure-config))
(*cache* (read-cache-file))
(*drafts* (read-drafts-file))
- (api:*host* (config-host *config*)))
- (handler-case
- (progn
- (assert api:*host* () "ol must be configured with a server host.")
- (set-term-width)
- ,@body
- ;; only if there is no error do we save the local state.
- (write-drafts-to-disk)
- (write-cache-to-disk)
- (write-config-to-disk))
- (dexador.error:http-request-failed (e)
- (format *error-output* "Operation failed. The server at ~a returned with ~a~%"
- api:*host*
- (dexador.error:response-status e)))
- (error (e)
- (format *error-output* "~a~%" e)))))
+ (api:*host* (config-host *config*))
+ (errorsp nil))
+ (unwind-protect
+ (handler-case
+ (progn
+ (assert api:*host* () "ol must be configured with a server host.")
+ (set-term-width)
+ ,@body)
+ (dexador.error:http-request-failed (e)
+ (setf errorsp t)
+ (format *error-output* "Operation failed. The server at ~a returned with ~a~%"
+ api:*host*
+ (dexador.error:response-status e)))
+ (error (e)
+ (setf errorsp t)
+ (format *error-output* "Unknown Error: ~a~%" e)))
+ (unless errorsp
+ (write-drafts-to-disk)
+ (write-cache-to-disk)
+ (write-config-to-disk)))))