;;;; draft.lisp (in-package :oneliners.cli.app) (defun draft/new/handler (cmd) (declare (ignore cmd)) (ol:add-new-oneliner)) (defun draft/new/command () (cli:make-command :name "new" :description "interactively draft a new oneliner" :handler #'draft/new/handler)) (defhandler draft/publish/handler (name) (ol::publish-draft name)) (defun draft/publish/command () (cli:make-command :name "publish" :usage "" :description "publish draft to the server" :handler #'draft/publish/handler)) (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 :name "test" :usage " [ARG ...]" :description "runs a draft oneliner, same options as `ol run`" :options (run/options) :handler #'draft/new/handler)) (defhandler draft/edit/handler (name) (ol:edit-item name t)) (defun draft/edit/command () (cli:make-command :name "edit" :usage "" :description "interactively edits a draft" :handler #'draft/edit/handler)) (defhandler draft/trash/handler (name) (ol::drop-draft name)) (defun draft/trash/command () (cli:make-command :name "trash" :usage "" :description "trash a draft" :handler #'draft/trash/handler)) (defun draft/list/handler (cmd) (declare (ignore cmd)) (ol::print-drafts)) (defun draft/list/command () (cli:make-command :name "list" :description "list drafted oneliners" :handler #'draft/list/handler)) (defun draft/subcommands () (list (draft/new/command) (draft/publish/command) (draft/test/command) (draft/edit/command) (draft/trash/command) (draft/list/command))) (defun draft/handler (cmd) (cli:print-usage-and-exit cmd t)) (defun draft/command () (cli:make-command :name "draft" :description "draft, test, and publish new oneliners" :handler #'draft/command :sub-commands (draft/subcommands)))