From 9a9f629068b4ffe7173bc92f12080685743dc6ab Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Fri, 5 Aug 2022 09:50:42 -0500 Subject: [add] defhandler macro for app package. --- app/modify.lisp | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 app/modify.lisp (limited to 'app/modify.lisp') diff --git a/app/modify.lisp b/app/modify.lisp new file mode 100644 index 0000000..0b5e53d --- /dev/null +++ b/app/modify.lisp @@ -0,0 +1,89 @@ +;;;; modify.lisp + +(in-package :oneliners.cli.app) + +;; ol modify flag +;; ol modify unflag +;; ol modify description new description ... +;; ol modify redraft +;; ol modify name New-name +;; ol modify lock +;; ol modify unlock + +(defhandler modify/redraft/handler (id) + (ol:edit-item (parse-identifier id))) + +(defun modify/redraft/command () + (cli:make-command + :name "redraft" + :usage "" + :description "edit an existing oneliner" + :handler #'modify/redraft/handler)) + +(defhandler modify/flag/handler (id) + (ol::flag-item (parse-identifier id))) + +(defun modify/flag/command () + (cli:make-command + :name "flag" + :usage "" + :description "flag a oneliner as potentially wrong or hazardous" + :handler #'modify/flag/handler)) + +(defhandler modify/unflag/handler (id) + (ol::unflag-item (parse-identifier id))) + +(defun modify/unflag/comnand () + (cli:make-command + :name "unflag" + :usage "" + :description "remove flagged status from a oneliner" + :handler #'modify/unflag/handler)) + +(defhandler modify/lock/handler (id) + (ol::lock-item (parse-identifier id))) + +(defun modify/lock/command () + (cli:make-command + :name "lock" + :usage "" + :description "lock a oneliner from being changed (admin only)" + :handler #'modify/lock/handler)) + +(defun modify/unlock/handler (id) + (ol::unlock-item (parse-identifier id))) + +(defun modify/unlock/command () + (cli:make-command + :name "unlock" + :usage "" + :description "unlock a locked oneliner, allowing it to be modified again" + :handler #'modify/unlock/handler)) + +(defun modify/delete/handler (id) + (ol::delete-item (parse-identifier id))) + +(defun modify/delete/command () + (cli:make-command + :name "delete" + :usage "" + :description "delete a oneliner from the server.")) + +(defun modify/subcommands () + (list + (modify/redraft/command) + (modify/flag/command) + (modify/unflag/command) + (modify/lock/command) + (modify/unlock/command) + (modify/delete/command))) + +(defun modify/handler (cmd) + (cli:print-usage-and-exit cmd t)) + +(defun modify/command () + (cli:make-command + :name "modify" + :description "alter an existing oneliner" + :handler #'modify/handler + :sub-commands (modify/subcommands))) -- cgit v1.2.3