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/draft.lisp | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'app/draft.lisp') diff --git a/app/draft.lisp b/app/draft.lisp index ea71e49..32698ca 100644 --- a/app/draft.lisp +++ b/app/draft.lisp @@ -3,6 +3,7 @@ (in-package :oneliners.cli.app) (defun draft/new/handler (cmd) + (declare (ignore cmd)) (ol:add-new-oneliner)) (defun draft/new/command () @@ -12,10 +13,8 @@ :handler #'draft/new/handler)) -(defun draft/publish/handler (cmd) - (a:if-let (name (first (cli:command-arguments cmd))) - (ol::publish-draft name) - (cli:print-usage-and-exit cmd t))) +(defhandler draft/publish/handler (name) + (ol::publish-draft name)) (defun draft/publish/command () (cli:make-command @@ -24,14 +23,12 @@ :description "publish draft to the server" :handler #'draft/publish/handler)) -(defun draft/test/handler (cmd) - (a:if-let (args (cli:command-arguments cmd)) - (ol:run-item (first args) (rest args) - :verbose (cli:getopt cmd :verbose) - :confirm (cli:getopt cmd :confirm) - :timeout (cli:getopt cmd :timeout) - :draftp t) - (cli:print-usage-and-exit cmd t))) +(defhandler draft/test/handler (name . args) + (ol:run-item name args + :verbose (cli:getopt *cmd* :verbose) + :confirm (cli:getopt *cmd* :confirm) + :timeout (cli:getopt *cmd* :timeout) + :draftp t)) (defun draft/test/command () (cli:make-command @@ -41,10 +38,8 @@ :options (run/options) :handler #'draft/new/handler)) -(defun draft/edit/handler (cmd) - (a:if-let (name (first (cli:command-arguments cmd))) - (ol:edit-item name t) - (cli:print-usage-and-exit cmd t))) +(defhandler draft/edit/handler (name) + (ol:edit-item name t)) (defun draft/edit/command () (cli:make-command @@ -53,10 +48,8 @@ :description "interactively edits a draft" :handler #'draft/edit/handler)) -(defun draft/trash/handler (cmd) - (a:if-let (name (first (cli:command-arguments cmd))) - (ol::drop-draft name) - (cli:print-usage-and-exit cmd t))) +(defhandler draft/trash/handler (name) + (ol::drop-draft name)) (defun draft/trash/command () (cli:make-command -- cgit v1.2.3