From 6d706967f1de63de80c83766053e896ab4792420 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Fri, 11 Mar 2022 10:33:19 -0600 Subject: refactoring client functions --- lib/oneliner.lisp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'lib/oneliner.lisp') diff --git a/lib/oneliner.lisp b/lib/oneliner.lisp index 48c78f6..ccfd3dc 100644 --- a/lib/oneliner.lisp +++ b/lib/oneliner.lisp @@ -64,3 +64,34 @@ (or (equal string "") (and (< 2 (length string)) (ppcre:scan "^[a-zA-Z][a-zA-Z0-9_\-]+$" string)))) + +;;; PRINTING + +(defun print-oneliner-result-for-user (ol) + "Prints information about the oneliner to the terminal." + (unless *term-width* (set-term-width)) ; setting here as a fallback, can set it elswere if desired. + (let* ((title-line-format-str + (concatenate 'string "~" (prin1-to-string *term-width*) "<[~a]~;~a~;~a~>~%")) + (tags-line-format-string + (concatenate 'string "~" (prin1-to-string *term-width*) "<~a~;by ~a~>~%"))) + (loop repeat *term-width* do (princ #\_)) + (terpri) + (with-slots + (id name isflagged islocked runstyle tags createdby brief oneliner) ol + + (format t title-line-format-str + id + (or name " ") + (format nil "~:[ ~;⚠~]~:[ ~;🔒~]~:[ ~;📋~]" + isflagged + islocked + (equalp "manual" runstyle))) + (format t tags-line-format-string + (format nil "tags: ~{~a~^ ~}" tags) + createdby) + (loop + for x from 0 to (length brief) by *term-width* + do (format t "~a~%" + (string-trim '(#\space) + (alexandria-2:subseq* brief x (+ x *term-width*))))) + (format t "~%~a~%~%" oneliner)))) -- cgit v1.2.3