Browse code
Adding support for comments
fiddlerwoaroof authored on 12/05/2016 16:21:48
Showing 3 changed files
Showing 3 changed files
... | ... |
@@ -12,7 +12,7 @@ |
12 | 12 |
(sheeple:defproto =status= () (name)) |
13 | 13 |
(sheeple:defproto =person= () (displayname emailaddress)) |
14 | 14 |
(sheeple:defproto =issue= () (fields key id self)) |
15 |
-(sheeple:defproto =fields= () (summary description reporter creator assignee status)) |
|
15 |
+(sheeple:defproto =fields= () (summary description reporter creator assignee status comment)) |
|
16 | 16 |
(sheeple:defmessage show (object &rest args)) |
17 | 17 |
(sheeple:defmessage fields-labels (fields)) |
18 | 18 |
(sheeple:defreply fields-labels ((fields =fields=)) |
... | ... |
@@ -22,7 +22,7 @@ |
22 | 22 |
(sheeple:defproto =comment= () (self id author body)) |
23 | 23 |
|
24 | 24 |
(sheeple:defreply sheeple:shared-init :after ((comment =comment=) &key) |
25 |
- (with-accessors ((author author)) issue |
|
25 |
+ (with-accessors ((author author)) comment |
|
26 | 26 |
(ensure-parent author =person= :err-if-nil nil))) |
27 | 27 |
|
28 | 28 |
(sheeple:defreply sheeple:shared-init :after ((issue =issue=) &key) |
... | ... |
@@ -33,11 +33,10 @@ |
33 | 33 |
(ensure-parent (reporter fields) =person=) |
34 | 34 |
(ensure-parent (creator fields) =person=) |
35 | 35 |
(ensure-parent (assignee fields) =person= :err-if-nil nil) |
36 |
- (when (sheeple:direct-property-p issue 'comment) |
|
37 |
- (sheeple:with-properties (comment) issue |
|
38 |
- (sheeple:with-properties (comments) comment |
|
39 |
- (map 'nil (lambda (comment) (ensure-parent comment =comment=)) |
|
40 |
- comments))))))) |
|
36 |
+ (sheeple:with-properties (comment) fields |
|
37 |
+ (sheeple:with-properties (comments) comment |
|
38 |
+ (map 'nil (lambda (comment) (ensure-parent comment =comment=)) |
|
39 |
+ comments)))))) |
|
41 | 40 |
|
42 | 41 |
(sheeple:defreply show ((person =person=) &rest args) |
43 | 42 |
(declare (ignore args)) |
... | ... |
@@ -78,7 +77,7 @@ |
78 | 77 |
(sheeple:defreply show ((issue =issue=) &rest args) |
79 | 78 |
(declare (ignorable args)) |
80 | 79 |
(with-output-to-string (*standard-output*) |
81 |
- (if-let ((fields (fields issue))) |
|
80 |
+ (when-let ((fields (fields issue))) |
|
82 | 81 |
(with-accessors ((status status) (summary summary) (reporter reporter) |
83 | 82 |
(creator creator) (assignee assignee) |
84 | 83 |
(labels fields-labels)) fields |
... | ... |
@@ -101,6 +100,19 @@ |
101 | 100 |
|
102 | 101 |
(when (description fields) |
103 | 102 |
(show-description (description fields)))) |
103 |
+ |
|
104 |
+ ; The head of the arguments determines whether or not |
|
105 |
+ ; we show the comments |
|
106 |
+ (when (and (car args)) |
|
107 |
+ (if-let ((comment (comment fields))) |
|
108 |
+ (sheeple:with-properties (comments) comment |
|
109 |
+ (loop for comment across comments |
|
110 |
+ do (format t "~&~a:~% ~< ~@;~{~{~a~^ ~:_~}~2%~}~:>~&" |
|
111 |
+ (show (author comment)) |
|
112 |
+ (list (map 'list #'tokens |
|
113 |
+ (split-sequence #\newline |
|
114 |
+ (body comment))))))))) |
|
115 |
+ |
|
104 | 116 |
(fresh-line)))) |
105 | 117 |
|
106 | 118 |
(sheeple:defproto =project= () (name key issuetypes)) |
... | ... |
@@ -39,6 +39,8 @@ |
39 | 39 |
:argument-name "URL-SUBDOMAIN" |
40 | 40 |
:default-value (ubiquitous:value :jira :account))) |
41 | 41 |
(group (:header "Filtering Issues") |
42 |
+ (flag :short-name "c" :long-name "with-comments" |
|
43 |
+ :description "Show the issue's comments") |
|
42 | 44 |
(stropt :short-name "s" :long-name "status" |
43 | 45 |
:description "Only show issues with a certain status")) |
44 | 46 |
(group (:header "Other options") |
... | ... |
@@ -81,7 +83,8 @@ |
81 | 83 |
(format nil "~a-~a" |
82 | 84 |
(car options) |
83 | 85 |
(cadr options))) |
84 |
- jira-api::=issue=))))) |
|
86 |
+ jira-api::=issue=) |
|
87 |
+ (getopt :long-name "with-comments"))))) |
|
85 | 88 |
((getopt :long-name "get-issues") |
86 | 89 |
(let ((options (remainder))) |
87 | 90 |
(let ((issues (jira-api::json2sheeple (jira-api::get-issues *auth*)))) |