aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.lisp35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/main.lisp b/src/main.lisp
index 2b64a57..e918b1b 100644
--- a/src/main.lisp
+++ b/src/main.lisp
@@ -84,13 +84,25 @@
:index-reader access-by-contributor))
(:metaclass db:persistent-class))
-
+(deftype runstyle ()
+ `(member :auto :manual))
(defclass oneliner (db:store-object)
((oneliner
:accessor oneliner
:initarg :oneliner
:initform (error "Onliner required"))
+ (runstyle
+ :accessor oneliner-runstyle
+ :initarg :runstyle
+ :initform :auto
+ :type runstyle
+ :documentation "If :manual, indicates that this oneliner is not suitable
+ for running from within another process, and should be run
+ directly. Hence, clients should copy the text of this oneliner to
+ the clipboard if possible. Examples include ncurses applications,
+ applications making use of readline, or those require extensive
+ user interaction.")
(tags
:accessor oneliner-tags
:initarg :tags
@@ -305,18 +317,23 @@
(defun make-new-oneliner (contributor plist)
(with-plist
- (oneliner tags brief description) plist
+ (oneliner tags brief description runstyle) plist
(unless brief
(http-err 400 "Oneliner requires a brief description"))
(unless oneliner
(http-err 400 "Oneliner cannot be blank"))
+ (when runstyle
+ (setf runstyle (a:make-keyword runstyle))
+ (unless (typep runstyle 'runstyle)
+ (http-err 400 "Invalid runstyle.")))
(db:with-transaction ()
(make-instance 'oneliner
:created-by contributor
:description (or description "")
:tags tags
:oneliner oneliner
- :brief brief))))
+ :brief brief
+ :runstyle (or runstyle :auto)))))
(defun flag-oneliner (oneliner &optional contributor)
"Flag a oneliner for review. If locked, ensure that CONTRIBUTOR is an admin. Returns T or NIL."
@@ -339,8 +356,12 @@
(defun edit-oneliner (ol contributor plist)
(when (or (not (lockedp ol)) (adminp contributor))
- (with-plist
- (oneliner tags brief description) plist
+ (with-plist
+ (oneliner tags brief description runstyle) plist
+ (when runstyle
+ (setf runstyle (a:make-keyword runstyle))
+ (unless (typep runstyle 'runstyle)
+ (http-err 400)))
(db:with-transaction ()
(when oneliner
(setf (oneliner ol) oneliner))
@@ -349,7 +370,9 @@
(when brief
(setf (oneliner-brief ol) brief))
(when description
- (setf (oneliner-description ol) description))))))
+ (setf (oneliner-description ol) description))
+ (when runstyle
+ (setf (oneliner-runstyle ol) runstyle))))))
;;; NONTRANSACTIONAL DATABASE QUERIES