bl 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d20d3678c35119bbab68027cdd10ba5dc75e4490
4
- data.tar.gz: cb4a885c2d366087ae8533344f307a1750cdd215
3
+ metadata.gz: 55f1e902cbc7a85e120ad076f71f125c5228eb4b
4
+ data.tar.gz: 1e65288f69871539a379a1b8edf6bd92f99def0b
5
5
  SHA512:
6
- metadata.gz: 57a13bd38a912c91c9be4deab150196c983d966ce5cfa3c4113c30b390a8a787b62df9b70af9744a9af20b8bbe31e3604ff1207c7580b91acf1c9e8e3c5cf93b
7
- data.tar.gz: 65a669111cee35f1719aafd872c489c5b7ad0b6fdf71c6ca4a3d28dd0649c3bde9a6d686c89633b4f7b1c7bc21f1d769efa5ed046bd8bf455db6ef6d28a98d17
6
+ metadata.gz: a564cf036ac05442c1f882b949ae14f7760e7ddf7891b892233c9f2534ff7a5264c10dba12ec4daaeefe6673abf2b7b4ee808df4e0f8382b2618ce80c6b3aa5b
7
+ data.tar.gz: d506a364760865d6c0d3388fac93c34c8ee1bc0e5da0c97b31af9d2db9716d67c039c557f7ffbd6795a6b41bf5577aa8afda9f894f0425c159ddef8b7318667f
@@ -10,14 +10,15 @@ module Bl
10
10
  desc 'list', 'list categories'
11
11
  def list
12
12
  res = client.get(@url)
13
- puts formatter.render(res.body, fields: %i(id name))
13
+ print_response(res)
14
14
  end
15
15
 
16
16
  desc 'add [NAME...]', 'add categories'
17
17
  def add(*names)
18
18
  names.each do |name|
19
19
  res = client.post(@url, name: name)
20
- puts "category added: #{res.body.id}\t#{res.body.name}"
20
+ puts 'category added'
21
+ print_response(res)
21
22
  end
22
23
  end
23
24
 
@@ -26,7 +27,8 @@ module Bl
26
27
  def update(*ids)
27
28
  ids.each do |id|
28
29
  res = client.patch("#{@url}/#{id}", delete_class_options(options))
29
- puts "category updated: #{res.body.id}\t#{res.body.name}"
30
+ puts 'category updated'
31
+ print_response(res)
30
32
  end
31
33
  end
32
34
 
@@ -34,8 +36,15 @@ module Bl
34
36
  def delete(*ids)
35
37
  ids.each do |id|
36
38
  res = client.delete("#{@url}/#{id}")
37
- puts "category deleted: #{res.body.id}\t#{res.body.name}"
39
+ puts 'category deleted'
40
+ print_response(res)
38
41
  end
39
42
  end
43
+
44
+ private
45
+
46
+ def print_response(res)
47
+ puts formatter.render(res.body, fields: CATEGORY_FIELDS)
48
+ end
40
49
  end
41
50
  end
@@ -2,69 +2,6 @@ module Bl
2
2
 
3
3
  class CLI < Command
4
4
 
5
- ISSUES_PARAMS = {
6
- projectId: :array,
7
- issueTypeId: :array,
8
- categoryId: :array,
9
- versionId: :array,
10
- milestoneId: :array,
11
- statusId: :array,
12
- priorityId: :array,
13
- assigneeId: :array,
14
- createdUserId: :array,
15
- resolutionId: :array,
16
- parentChild: :numeric,
17
- attachment: :boolean,
18
- sharedFile: :boolean,
19
- sort: :string,
20
- order: :string,
21
- offset: :numeric,
22
- count: :numeric,
23
- createdSince: :string,
24
- createUntil: :string,
25
- updatedSince: :string,
26
- updatedUntil: :string,
27
- startDateSince: :string,
28
- startDateUntil: :string,
29
- dueDateSince: :string,
30
- dueDateUntil: :string,
31
- id: :array,
32
- parentIssueId: :array,
33
- keyword: :string
34
- }
35
-
36
- ISSUE_BASE_ATTRIBUTES = {
37
- summary: :string,
38
- description: :string,
39
- statusId: :numeric,
40
- resolutionId: :numeric,
41
- dueDate: :string,
42
- issueTypeId: :numeric,
43
- categoryId: :array,
44
- versionId: :array,
45
- milestoneId: :array,
46
- priorityId: :numeric,
47
- assigneeId: :numeric
48
- }
49
-
50
- ISSUE_FIELDS = %i(
51
- issueKey
52
- summary
53
- startDate
54
- dueDate
55
- created
56
- updated
57
- )
58
-
59
- ROLES = [
60
- {id: 1, name: 'Administrator'},
61
- {id: 2, name: 'Normal User'},
62
- {id: 3, name: 'Reporter'},
63
- {id: 4, name: 'Viewer'},
64
- {id: 5, name: 'Guest Reporter'},
65
- {id: 6, name: 'Guest Viewer'}
66
- ]
67
-
68
5
  def initialize(*)
69
6
  @config = Bl::Config.instance
70
7
  super
@@ -4,7 +4,169 @@ module Bl
4
4
  include Bl::Formatting
5
5
  class_option :format, type: :string, default: 'table', desc: 'set output format'
6
6
 
7
+ ACTIVITY_TYPES = {
8
+ 1 => 'Issue Created',
9
+ 2 => 'Issue Updated',
10
+ 3 => 'Issue Commented',
11
+ 4 => 'Issue Deleted',
12
+ 5 => 'Wiki Created',
13
+ 6 => 'Wiki Updated',
14
+ 7 => 'Wiki Deleted',
15
+ 8 => 'File Added',
16
+ 9 => 'File Updated',
17
+ 10 => 'File Deleted',
18
+ 11 => 'SVN Committed',
19
+ 12 => 'Git Pushed',
20
+ 13 => 'Git Repository Created',
21
+ 14 => 'Issue Multi Updated',
22
+ 15 => 'Project User Added',
23
+ 16 => 'Project User Deleted',
24
+ 17 => 'Comment Notification Added',
25
+ 18 => 'Pull Request Added',
26
+ 19 => 'Pull Request Updated',
27
+ 20 => 'Comment Added on Pull Request'
28
+ }
29
+ CATEGORY_FIELDS = %i(id name displayOrder)
30
+ FILE_FIELDS = %i(id type dir name size created updated)
31
+ GIT_REPO_FIELDS = %i(
32
+ id
33
+ projectId
34
+ name
35
+ sshUrl
36
+ pushedAt
37
+ created
38
+ updated
39
+ )
40
+ ISSUE_BASE_ATTRIBUTES = {
41
+ summary: :string,
42
+ description: :string,
43
+ statusId: :numeric,
44
+ resolutionId: :numeric,
45
+ dueDate: :string,
46
+ issueTypeId: :numeric,
47
+ categoryId: :array,
48
+ versionId: :array,
49
+ milestoneId: :array,
50
+ priorityId: :numeric,
51
+ assigneeId: :numeric
52
+ }
53
+ ISSUE_FIELDS = %i(
54
+ issueKey
55
+ summary
56
+ startDate
57
+ dueDate
58
+ created
59
+ updated
60
+ )
61
+ ISSUES_PARAMS = {
62
+ projectId: :array,
63
+ issueTypeId: :array,
64
+ categoryId: :array,
65
+ versionId: :array,
66
+ milestoneId: :array,
67
+ statusId: :array,
68
+ priorityId: :array,
69
+ assigneeId: :array,
70
+ createdUserId: :array,
71
+ resolutionId: :array,
72
+ parentChild: :numeric,
73
+ attachment: :boolean,
74
+ sharedFile: :boolean,
75
+ sort: :string,
76
+ order: :string,
77
+ offset: :numeric,
78
+ count: :numeric,
79
+ createdSince: :string,
80
+ createUntil: :string,
81
+ updatedSince: :string,
82
+ updatedUntil: :string,
83
+ startDateSince: :string,
84
+ startDateUntil: :string,
85
+ dueDateSince: :string,
86
+ dueDateUntil: :string,
87
+ id: :array,
88
+ parentIssueId: :array,
89
+ keyword: :string
90
+ }
91
+ MILESTONE_FIELDS = %i(id projectId name description startDate releaseDueDate archived)
92
+ MILESTONE_PARAMS = {
93
+ description: :string,
94
+ startDate: :string,
95
+ releaseDueDate: :string
96
+ }
97
+ PROJECT_FIELDS = %i(
98
+ id
99
+ projectKey
100
+ name
101
+ chartEnabled
102
+ subtaskingEnabled
103
+ projectLeaderCanEditProjectLeader
104
+ textFormattingRule
105
+ archived
106
+ )
107
+ ROLES = [
108
+ {id: 1, name: 'Administrator'},
109
+ {id: 2, name: 'Normal User'},
110
+ {id: 3, name: 'Reporter'},
111
+ {id: 4, name: 'Viewer'},
112
+ {id: 5, name: 'Guest Reporter'},
113
+ {id: 6, name: 'Guest Viewer'}
114
+ ]
115
+ SPACE_FIELDS = %i(
116
+ spaceKey
117
+ name
118
+ ownerId
119
+ lang
120
+ timezone
121
+ reportSendTime
122
+ textFormattingRule
123
+ created
124
+ updated
125
+ )
7
126
  TPUT_COLS = `tput cols`.to_i
127
+ TYPE_COLORS = %w(
128
+ #e30000
129
+ #934981
130
+ #814fbc
131
+ #007e9a
132
+ #ff3265
133
+ #666665
134
+ #990000
135
+ #2779ca
136
+ #7ea800
137
+ #ff9200
138
+ )
139
+ USER_FIELDS = %i(
140
+ id
141
+ userId
142
+ name
143
+ roleType
144
+ lang
145
+ mailAddress
146
+ )
147
+ USER_PARAMS = {
148
+ password: :string,
149
+ name: :string,
150
+ mailAddress: :string,
151
+ roleType: :numeric
152
+ }
153
+ WATCHINGS_PARAMS = {
154
+ order: :string,
155
+ sort: :string,
156
+ count: :numeric,
157
+ offset: :numeric,
158
+ resourceAlreadyRead: :boolean,
159
+ issueId: :array
160
+ }
161
+ WEBHOOK_FIELDS = %i(id name description created updated)
162
+ WEBHOOK_PARAMS = {
163
+ name: :string,
164
+ description: :string,
165
+ hookUrl: :string,
166
+ allEvent: :boolean,
167
+ activityTypeIds: :array
168
+ }
169
+ WIKI_FIELDS = %i(id projectId name created updated)
8
170
 
9
171
  protected
10
172
 
@@ -1,26 +1,32 @@
1
1
  module Bl
2
2
  class File < Command
3
-
4
3
  def initialize(*)
5
4
  @config = Bl::Config.instance
5
+ @url = "projects/#{@config[:project_key]}"
6
6
  super
7
7
  end
8
8
 
9
9
  desc 'list PATH', 'list files on PATH'
10
- def list(path='')
11
- res = client.get("projects/#{@config[:project_key]}/files/metadata/#{path}")
12
- puts formatter.render(res.body, fields: %i(id type dir name size created updated))
10
+ def list(path = '')
11
+ res = client.get("#{@url}/files/metadata/#{path}")
12
+ print_response(res)
13
13
  end
14
14
 
15
15
  desc 'get [ID...]', 'get files'
16
16
  def get(*ids)
17
17
  ids.each do |id|
18
- res = client.get("projects/#{@config[:project_key]}/files/#{id}")
19
- f = ::File.new(res.body.filename, "w")
18
+ res = client.get("#{@url}/files/#{id}")
19
+ f = ::File.new(res.body.filename, 'w')
20
20
  f.write(res.body.content)
21
21
  f.close
22
22
  puts "file #{id} #{res.body.filename} downloaded."
23
23
  end
24
24
  end
25
+
26
+ private
27
+
28
+ def print_response(res)
29
+ puts formatter.render(res.body, fields: FILE_FIELDS)
30
+ end
25
31
  end
26
32
  end
@@ -2,29 +2,6 @@ module Bl
2
2
  module Formatting
3
3
  module_function
4
4
 
5
- ACTIVITY_TYPES = {
6
- 1 => 'Issue Created',
7
- 2 => 'Issue Updated',
8
- 3 => 'Issue Commented',
9
- 4 => 'Issue Deleted',
10
- 5 => 'Wiki Created',
11
- 6 => 'Wiki Updated',
12
- 7 => 'Wiki Deleted',
13
- 8 => 'File Added',
14
- 9 => 'File Updated',
15
- 10 => 'File Deleted',
16
- 11 => 'SVN Committed',
17
- 12 => 'Git Pushed',
18
- 13 => 'Git Repository Created',
19
- 14 => 'Issue Multi Updated',
20
- 15 => 'Project User Added',
21
- 16 => 'Project User Deleted',
22
- 17 => 'Comment Notification Added',
23
- 18 => 'Pull Request Added',
24
- 19 => 'Pull Request Updated',
25
- 20 => 'Comment Added on Pull Request'
26
- }
27
-
28
5
  def colorize_type(name, color)
29
6
  Paint[name, :white, color]
30
7
  end
@@ -10,25 +10,19 @@ module Bl
10
10
  desc 'list', 'list git repositories'
11
11
  def list
12
12
  res = client.get(@url)
13
- puts formatter.render(res.body, fields: %i(id projectId name description sshUrl))
13
+ print_response(res)
14
14
  end
15
15
 
16
16
  desc 'show ID', 'show a git repository'
17
17
  def show(id)
18
- body = client.get("#{@url}/#{id}").body
19
- puts "id: #{body.id}"
20
- puts "projectId: #{body.projectId}"
21
- puts "name: #{body.name}"
22
- puts "description: #{body.description}"
23
- puts "hookUrl: #{body.hookUrl}"
24
- puts "httpUrl: #{body.httpUrl}"
25
- puts "sshUrl: #{body.sshUrl}"
26
- puts "displayOrder: #{body.displayOrder}"
27
- puts "pushedAt: #{body.pushedAt}"
28
- puts "createdUser: #{body.createdUser.name}"
29
- puts "created: #{body.created}"
30
- puts "updatedUser: #{body.updatedUser.name}"
31
- puts "updated: #{body.updated}"
18
+ res = client.get("#{@url}/#{id}")
19
+ puts formatter.render(res.body, fields: GIT_REPO_FIELDS, vertical: true)
20
+ end
21
+
22
+ private
23
+
24
+ def print_response(res)
25
+ puts formatter.render(res.body, fields: GIT_REPO_FIELDS)
32
26
  end
33
27
  end
34
28
  end
@@ -17,7 +17,7 @@ module Bl
17
17
  desc 'show GROUP_ID', ''
18
18
  def show(id)
19
19
  res = client.get("#{@url}/#{id}")
20
- puts formatter.render(res.body.members, fields: %i(id userId name roleType lang mailAddress))
20
+ puts formatter.render(res.body.members, fields: USER_FIELDS)
21
21
  end
22
22
 
23
23
  desc 'add GROUP_NAME', ''
@@ -1,12 +1,6 @@
1
1
  module Bl
2
2
  class Milestone < Command
3
3
 
4
- MILESTONE_PARAMS = {
5
- description: :string,
6
- startDate: :string,
7
- releaseDueDate: :string
8
- }
9
-
10
4
  def initialize(*)
11
5
  @config = Bl::Config.instance
12
6
  @url = "projects/#{@config[:project_key]}/versions"
@@ -18,11 +12,10 @@ module Bl
18
12
  def list
19
13
  res = client.get(@url)
20
14
  if options[:all]
21
- body = res.body
22
15
  else
23
- body = res.body.select { |m| m.archived == false } unless options[:all]
16
+ res.body.select! { |m| m.archived == false } unless options[:all]
24
17
  end
25
- puts formatter.render(body, fields: %i(id projectId name description startDate releaseDueDate archived))
18
+ print_response(res)
26
19
  end
27
20
 
28
21
  desc 'add [NAME...]', 'add milestones'
@@ -36,7 +29,8 @@ module Bl
36
29
  startDate: options[:startDate],
37
30
  releaseDueDate: options[:releaseDueDate]
38
31
  )
39
- puts "milestone added: #{res.body.id}\t#{res.body.name}"
32
+ puts 'milestone added'
33
+ print_response(res)
40
34
  end
41
35
  end
42
36
 
@@ -46,7 +40,8 @@ module Bl
46
40
  def update(*ids)
47
41
  ids.each do |id|
48
42
  res = client.patch("#{@url}/#{id}", delete_class_options(options))
49
- puts "milestone updated: #{res.body.id}\t#{res.body.name}"
43
+ puts 'milestone updated'
44
+ print_response(res)
50
45
  end
51
46
  end
52
47
 
@@ -54,8 +49,15 @@ module Bl
54
49
  def delete(*ids)
55
50
  ids.each do |id|
56
51
  res = client.delete("#{@url}/#{id}")
57
- puts "milestone deleted: #{res.body.id}\t#{res.body.name}"
52
+ puts 'milestone deleted'
53
+ print_response(res)
58
54
  end
59
55
  end
56
+
57
+ private
58
+
59
+ def print_response(res)
60
+ puts formatter.render(res.body, fields: MILESTONE_FIELDS)
61
+ end
60
62
  end
61
63
  end
@@ -1,6 +1,5 @@
1
1
  module Bl
2
2
  class Project < Command
3
-
4
3
  def initialize(*)
5
4
  @config = Bl::Config.instance
6
5
  @url = 'projects'
@@ -10,7 +9,7 @@ module Bl
10
9
  desc 'list', 'list projects'
11
10
  def list
12
11
  res = client.get(@url)
13
- puts formatter.render(res.body, fields: %i(id projectKey name))
12
+ puts formatter.render(res.body, fields: PROJECT_FIELDS)
14
13
  end
15
14
 
16
15
  desc 'status ID', 'show project status'
@@ -51,16 +50,8 @@ module Bl
51
50
 
52
51
  desc 'users ID', 'show project users'
53
52
  def users(id)
54
- client.get("#{@url}/#{id}/users").body.each do |u|
55
- puts [
56
- u.id,
57
- u.userId,
58
- u.name,
59
- u.roleType,
60
- u.lang,
61
- u.mailAddress
62
- ].join("\t")
63
- end
53
+ res = client.get("#{@url}/#{id}/users")
54
+ puts formatter.render(res.body, fields: USER_FIELDS)
64
55
  end
65
56
 
66
57
  private
@@ -8,7 +8,8 @@ module Bl
8
8
 
9
9
  desc 'info', 'show space info'
10
10
  def info
11
- puts client.get('space').body.inspect
11
+ res = client.get('space')
12
+ puts formatter.render(res.body, fields: SPACE_FIELDS)
12
13
  end
13
14
 
14
15
  desc 'activities', 'show space activities'
@@ -1,19 +1,6 @@
1
1
  module Bl
2
2
  class Type < Command
3
3
 
4
- TYPE_COLORS = %w(
5
- #e30000
6
- #934981
7
- #814fbc
8
- #007e9a
9
- #ff3265
10
- #666665
11
- #990000
12
- #2779ca
13
- #7ea800
14
- #ff9200
15
- )
16
-
17
4
  def initialize(*)
18
5
  @config = Bl::Config.instance
19
6
  @url = "projects/#{@config[:project_key]}/issueTypes"
@@ -23,7 +10,7 @@ module Bl
23
10
  desc 'list', 'list issue types'
24
11
  def list
25
12
  res = client.get(@url)
26
- puts formatter.render(res.body, fields: %i(id name color))
13
+ print_response(res)
27
14
  end
28
15
 
29
16
  desc 'add [NAME...]', 'add types'
@@ -31,7 +18,8 @@ module Bl
31
18
  def add(*names)
32
19
  names.each do |name|
33
20
  res = client.post(@url, name: name, color: options[:color])
34
- puts "type added: #{res.body.id}\t#{res.body.name}\t#{res.body.color}"
21
+ puts 'type added'
22
+ print_response(res)
35
23
  end
36
24
  end
37
25
 
@@ -41,7 +29,8 @@ module Bl
41
29
  def update(*ids)
42
30
  ids.each do |id|
43
31
  res = client.patch("#{@url}/#{id}", options)
44
- puts "type updated: #{res.body.id}\t#{res.body.name}\t#{res.body.color}"
32
+ puts 'type updated'
33
+ print_response(res)
45
34
  end
46
35
  end
47
36
 
@@ -50,7 +39,8 @@ module Bl
50
39
  def delete(*ids)
51
40
  ids.each do |id|
52
41
  res = client.delete("#{@url}/#{id}", options)
53
- puts "type deleted: #{res.body.id}\t#{res.body.name}\t#{res.body.color}"
42
+ puts 'type deleted'
43
+ print_response
54
44
  end
55
45
  end
56
46
 
@@ -60,5 +50,11 @@ module Bl
60
50
  puts Paint[color, '#ffffff', color]
61
51
  end
62
52
  end
53
+
54
+ private
55
+
56
+ def print_response(res)
57
+ puts formatter.render(res.body, fields: %i(id name color))
58
+ end
63
59
  end
64
60
  end
@@ -1,22 +1,6 @@
1
1
  module Bl
2
2
  class Users < Command
3
3
 
4
- USER_FIELDS = %i(
5
- id
6
- userId
7
- name
8
- roleType
9
- lang
10
- mailAddress
11
- )
12
-
13
- USER_PARAMS = {
14
- password: :string,
15
- name: :string,
16
- mailAddress: :string,
17
- roleType: :numeric
18
- }
19
-
20
4
  def initialize(*)
21
5
  @config = Bl::Config.instance
22
6
  @url = 'users'
@@ -26,7 +10,7 @@ module Bl
26
10
  desc 'list', 'list users'
27
11
  def list
28
12
  res = client.get('users')
29
- puts formatter.render(res.body, fields: USER_FIELDS)
13
+ print_response(res)
30
14
  end
31
15
 
32
16
  desc 'show USER_ID', ''
@@ -38,7 +22,8 @@ module Bl
38
22
  desc 'add USER_ID PASSWORD NAME MAIL_ADDRESS ROLE_TYPE', ''
39
23
  def add(id, pass, name, mail_address, role_type)
40
24
  res = client.post("#{@url}", userId: id, password: pass, name: name, mailAddress: mail_address, roleType: role_type)
41
- puts formatter.render(res.body, fields: USER_FIELDS)
25
+ puts 'user added'
26
+ print_response(res)
42
27
  end
43
28
 
44
29
  desc 'update USER_ID', ''
@@ -46,20 +31,20 @@ module Bl
46
31
  def update(id)
47
32
  res = client.patch("#{@url}/#{id}", delete_class_options(options.to_h))
48
33
  puts 'user updated:'
49
- puts formatter.render(res.body, fields: USER_FIELDS)
34
+ print_response(res)
50
35
  end
51
36
 
52
37
  desc 'delete', ''
53
38
  def delete(id)
54
39
  res = client.delete("#{@url}/#{id}")
55
40
  puts 'user deleted'
56
- puts formatter.render(res.body, fields: USER_FIELDS)
41
+ print_response(res)
57
42
  end
58
43
 
59
44
  desc 'myself', ''
60
45
  def myself
61
46
  res = client.get("#{@url}/myself")
62
- puts formatter.render(res.body, fields: USER_FIELDS)
47
+ print_response(res)
63
48
  end
64
49
 
65
50
  desc 'icon ID', ''
@@ -91,5 +76,11 @@ module Bl
91
76
  p client.get("/users/#{user_id}/stars/count", options.to_h).body.count
92
77
  end
93
78
  end
79
+
80
+ private
81
+
82
+ def print_response(res)
83
+ formatter.render(res.body, fields: USER_FIELDS)
84
+ end
94
85
  end
95
86
  end
@@ -1,3 +1,3 @@
1
1
  module Bl
2
- VERSION = '0.5.3'.freeze
2
+ VERSION = '0.5.4'.freeze
3
3
  end
@@ -1,15 +1,6 @@
1
1
  module Bl
2
2
  class Watchings < Command
3
3
 
4
- WATCHINGS_PARAMS = {
5
- order: :string,
6
- sort: :string,
7
- count: :numeric,
8
- offset: :numeric,
9
- resourceAlreadyRead: :boolean,
10
- issueId: :array
11
- }
12
-
13
4
  def initialize(*)
14
5
  @config = Bl::Config.instance
15
6
  @url = 'watchings'
@@ -1,14 +1,6 @@
1
1
  module Bl
2
2
  class Webhooks < Command
3
3
 
4
- WEBHOOK_PARAMS = {
5
- name: :string,
6
- description: :string,
7
- hookUrl: :string,
8
- allEvent: :boolean,
9
- activityTypeIds: :array
10
- }
11
-
12
4
  def initialize(*)
13
5
  @config = Bl::Config.instance
14
6
  @url = "projects/#{@config[:project_key]}/webhooks"
@@ -18,13 +10,13 @@ module Bl
18
10
  desc 'list', ''
19
11
  def list
20
12
  res = client.get(@url)
21
- puts formatter.render(res.body, fields: %i(id name description hookUrl))
13
+ print_response(res)
22
14
  end
23
15
 
24
16
  desc 'show WEBHOOK_ID', ''
25
17
  def show(id)
26
18
  res = client.get("#{@url}/#{id}")
27
- print_webhook(res.body)
19
+ print_response(res)
28
20
  end
29
21
 
30
22
  desc 'add', ''
@@ -32,7 +24,7 @@ module Bl
32
24
  def add
33
25
  res = client.post(@url, options.to_h)
34
26
  puts 'webhook added'
35
- print_webhook(res.body)
27
+ print_response(res)
36
28
  end
37
29
 
38
30
  desc 'update WEBHOOK_ID', ''
@@ -40,14 +32,20 @@ module Bl
40
32
  def update(id)
41
33
  res = client.patch("#{@url}/#{id}", options.to_h)
42
34
  puts 'webhook updated'
43
- print_webhook(res.body)
35
+ print_response(res)
44
36
  end
45
37
 
46
38
  desc 'delete WEBHOOK_ID', ''
47
39
  def delete(id)
48
40
  res = client.delete("#{@url}/#{id}")
49
41
  puts 'webhook deleted'
50
- print_webhook(res.body)
42
+ print_response(res)
43
+ end
44
+
45
+ private
46
+
47
+ def print_response(res)
48
+ puts formatter.render(res.body, fields: WEBHOOK_FIELDS)
51
49
  end
52
50
  end
53
51
  end
@@ -10,7 +10,7 @@ module Bl
10
10
  desc 'list', 'list wikis'
11
11
  def list
12
12
  res = client.get(@url, projectIdOrKey: @config[:project_key])
13
- puts formatter.render(res.body, fields: %i(id projectId name updated))
13
+ puts formatter.render(res.body, fields: WIKI_FIELDS)
14
14
  end
15
15
 
16
16
  desc 'show ID', "show a wiki's content"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - saki