blob: b3ca67c13b91fc498a83451b14a410db2d2e0ca9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
;;;; 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 "<DRAFT>"
: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 "[options] <draft-name> [ARG ...]"
:description "runs a draft oneliner, same options as `ol run`"
:options (run/options)
:handler #'draft/test/handler))
(defhandler draft/edit/handler (name)
(ol:edit-item name t))
(defun draft/edit/command ()
(cli:make-command
:name "edit"
:usage "<DRAFT>"
: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 "<DRAFT>"
: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 cmd t))
(defun draft/command ()
(cli:make-command
:name "draft"
:description "draft, test, and publish new oneliners"
:handler #'draft/handler
:sub-commands (draft/subcommands)))
|