bl 0.3.1 → 0.4.0

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: 2b63ca5c0491487914743088a862ad66be1b0e92
4
- data.tar.gz: 9193864021bb6e7b2c0b5b0f0bfd3221a322d0c7
3
+ metadata.gz: 15d8d5ac4f5758bc9d04bcf3712361004a1f54bc
4
+ data.tar.gz: 97c3f152219dd02ba579ca23398fcb61321919f9
5
5
  SHA512:
6
- metadata.gz: 0d21146deffffc2fa10231b1664cca03b28d1b8f6202ba78a233dbe178760e377565eb9fce3157662e9e6d8067580bebd0efbe83838dd4b9bfa5c52d8c84ad22
7
- data.tar.gz: 31dbe2f7d1827b9508429b4689ce4b9b5b1744b691752e7ac384c5c72224d8ada833e131d45a55e82172ebbed08639c33d37faec99a0b430147af48c7143d160
6
+ metadata.gz: f07c599d63592fa6657737d2756eacd4bd3e918a28b2608e38656963289ec7eb4ac894b68a944b9bfd3cf02810398439f4f57816620bf6947c5ffa1c41600283
7
+ data.tar.gz: 80b0dd6c11cd1a7dbdfe9f716e691f0b204f344737343c82f8b0690118cb9554a4282ad90ce7e1b507179d2e302a6e17bbd0f395a31606d94078d479e65b7b36
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  /*.gem
11
+ tags
data/README.md CHANGED
@@ -42,34 +42,39 @@ bl uses `~/.bl.yml` for configuration.
42
42
 
43
43
  ## Usage
44
44
 
45
- bl activities # list activities
46
- bl add [SUBJECT...] # add issues
47
- bl browse KEY # browse an issue
48
- bl category SUBCOMMAND ...ARGS # manage categories
49
- bl close [KEY...] # close issues
50
- bl config # show config
51
- bl count # count issues
52
- bl doctor # check issues
53
- bl edit KEY # edit issues' description by $EDITOR
54
- bl file SUBCOMMAND ...ARGS # manage files
55
- bl help [COMMAND] # Describe available commands or one specific command
56
- bl init # initialize a default config file
57
- bl list # list issues by typical ways
58
- bl milestone SUBCOMMAND ...ARGS # manage milestones
59
- bl notifications # list notifications
60
- bl priorities # list priorities
61
- bl project SUBCOMMAND ...ARGS # manage projects
62
- bl recent SUBCOMMAND ...ARGS # list recent stuff
63
- bl resolutions # list resolutions
64
- bl search # search issues
65
- bl show KEY # show an issue's details
66
- bl space # show space info
67
- bl statuses # list statuses
68
- bl type SUBCOMMAND ...ARGS # manage types
69
- bl update [KEY...] # update issues
70
- bl users # list space users
71
- bl version # show version
72
- bl wiki SUBCOMMAND ...ARGS # manage wikis
45
+ ```
46
+ bl add [SUBJECT...] # add issues
47
+ bl browse KEY # browse an issue
48
+ bl category SUBCOMMAND ...ARGS # manage categories
49
+ bl close [KEY...] # close issues
50
+ bl config # show config
51
+ bl count # count issues
52
+ bl doctor # check issues
53
+ bl edit KEY # edit issues' description by $EDITOR
54
+ bl file SUBCOMMAND ...ARGS # manage files
55
+ bl gitrepo SUBCOMMAND ...ARGS # show gitrepos
56
+ bl groups SUBCOMMAND ...ARGS #
57
+ bl help [COMMAND] # Describe available commands or one specific command
58
+ bl init # initialize a default config file
59
+ bl list # list issues by typical ways
60
+ bl milestone SUBCOMMAND ...ARGS # manage milestones
61
+ bl notifications SUBCOMMAND ...ARGS #
62
+ bl priorities # list priorities
63
+ bl project SUBCOMMAND ...ARGS # manage projects
64
+ bl recent SUBCOMMAND ...ARGS # list recent stuff
65
+ bl resolutions # list resolutions
66
+ bl search # search issues
67
+ bl show KEY # show an issue's details
68
+ bl space SUBCOMMAND ...ARGS #
69
+ bl statuses # list statuses
70
+ bl type SUBCOMMAND ...ARGS # manage types
71
+ bl update [KEY...] # update issues
72
+ bl users SUBCOMMAND ...ARGS #
73
+ bl version # show version
74
+ bl watchings SUBCOMMAND ...ARGS #
75
+ bl webhooks SUBCOMMAND ...ARGS #
76
+ bl wiki SUBCOMMAND ...ARGS # manage wikis
77
+ ```
73
78
 
74
79
  View global or command specific help:
75
80
 
@@ -134,16 +139,6 @@ Download file:
134
139
 
135
140
  bl file get 12345
136
141
 
137
- ### Git repository
138
-
139
- List repositories:
140
-
141
- bl gitrepo list
142
-
143
- Show repository:
144
-
145
- bl gitrepo show 12345
146
-
147
142
  ## Backlog API
148
143
 
149
144
  http://developer.nulab-inc.com/docs/backlog
data/lib/bl.rb CHANGED
@@ -16,6 +16,11 @@ require 'bl/project'
16
16
  require 'bl/recent'
17
17
  require 'bl/file'
18
18
  require 'bl/gitrepo'
19
+ require 'bl/users'
20
+ require 'bl/groups'
21
+ require 'bl/webhooks'
22
+ require 'bl/notifications'
23
+ require 'bl/watchings'
19
24
  require 'bl/cli'
20
25
 
21
26
  Bl::CLI.start(ARGV)
@@ -222,36 +222,6 @@ module Bl
222
222
  end
223
223
  end
224
224
 
225
- desc 'users', 'list space users'
226
- def users
227
- client.get('users').body.each do |u|
228
- puts [u.id, u.userId, u.name, u.roleType, u.lang, u.mailAddress].join("\t")
229
- end
230
- end
231
-
232
- desc 'user-activities USER_ID', "list user's activities"
233
- options activityTypeId: :array, minId: :numeric, maxId: :numeric, count: :numeric, order: :string
234
- def user_activities(user_id)
235
- client.get("/users/#{user_id}/activities").body.each do |a|
236
- print_activity(a)
237
- end
238
- end
239
-
240
- desc 'user-stars-count [USER_ID...]', 'count user stars'
241
- options since: :string, until: :string
242
- def user_stars_count(*user_ids)
243
- user_ids.each do |user_id|
244
- p client.get("/users/#{user_id}/stars/count", options.to_h).body.count
245
- end
246
- end
247
-
248
- desc 'notifications', 'list notifications'
249
- def notifications
250
- client.get('notifications').body.each do |n|
251
- puts n.pretty_inspect
252
- end
253
- end
254
-
255
225
  desc 'doctor', 'check issues'
256
226
  def doctor
257
227
  unassigned_issues = client.get('issues', assigneeId: [-1]).body
@@ -275,6 +245,12 @@ module Bl
275
245
  desc 'space SUBCOMMAND ...ARGS', ''
276
246
  subcommand 'space', Space
277
247
 
248
+ desc 'users SUBCOMMAND ...ARGS', ''
249
+ subcommand 'users', Users
250
+
251
+ desc 'groups SUBCOMMAND ...ARGS', ''
252
+ subcommand 'groups', Groups
253
+
278
254
  desc 'type SUBCOMMAND ...ARGS', 'manage types'
279
255
  subcommand 'type', Type
280
256
 
@@ -298,5 +274,14 @@ module Bl
298
274
 
299
275
  desc 'gitrepo SUBCOMMAND ...ARGS', 'show gitrepos'
300
276
  subcommand 'gitrepo', GitRepo
277
+
278
+ desc 'webhooks SUBCOMMAND ...ARGS', ''
279
+ subcommand 'webhooks', Webhooks
280
+
281
+ desc 'notifications SUBCOMMAND ...ARGS', ''
282
+ subcommand 'notifications', Notifications
283
+
284
+ desc 'watchings SUBCOMMAND ...ARGS', ''
285
+ subcommand 'watchings', Watchings
301
286
  end
302
287
  end
@@ -80,5 +80,46 @@ module Bl
80
80
  a.created
81
81
  ].join("\t")
82
82
  end
83
+
84
+ def print_user(user)
85
+ puts [
86
+ user.id,
87
+ user.userId,
88
+ user.name,
89
+ user.roleType,
90
+ user.lang,
91
+ user.mailAddress
92
+ ].join("\t")
93
+ end
94
+
95
+ def print_group(group)
96
+ puts [
97
+ group.id,
98
+ group.name
99
+ ].join("\t")
100
+ end
101
+
102
+ def print_group_members(members)
103
+ members.map { |m| print_user(m) }
104
+ end
105
+
106
+ def print_group_and_members(group)
107
+ print_group(group)
108
+ puts 'members:'
109
+ print_group_members(group.members)
110
+ end
111
+
112
+ def print_webhook(webhook)
113
+ puts [
114
+ webhook.id,
115
+ webhook.name,
116
+ webhook.description,
117
+ webhook.hookUrl
118
+ ].join("\t")
119
+ end
120
+
121
+ def print_watch_target(target)
122
+ p target
123
+ end
83
124
  end
84
125
  end
@@ -0,0 +1,48 @@
1
+ module Bl
2
+ class Groups < Thor
3
+ include Bl::Requestable
4
+ include Bl::Formatting
5
+
6
+ def initialize(*)
7
+ @config = Bl::Config.instance
8
+ @url = 'groups'
9
+ super
10
+ end
11
+
12
+ desc 'list', ''
13
+ options order: :string, offset: :numeric, count: :numeric
14
+ def list
15
+ res = client.get(@url, options.to_h)
16
+ res.body.map { |g| print_group(g) }
17
+ end
18
+
19
+ desc 'show GROUP_ID', ''
20
+ def show(id)
21
+ res = client.get("#{@url}/#{id}")
22
+ print_group_and_members(res.body)
23
+ end
24
+
25
+ desc 'add GROUP_NAME', ''
26
+ options members: :array
27
+ def add(name)
28
+ res = client.post(@url, {name: name}.merge(options))
29
+ puts 'group added'
30
+ print_group_and_members(res.body)
31
+ end
32
+
33
+ desc 'update GROUP_ID', ''
34
+ options name: :string, members: :array
35
+ def update(id)
36
+ res = client.patch("#{@url}/#{id}", options.to_h)
37
+ puts 'group updated'
38
+ print_group_and_members(res.body)
39
+ end
40
+
41
+ desc 'delete GROUP_ID', ''
42
+ def delete(id)
43
+ res = client.delete("#{@url}/#{id}")
44
+ puts 'group deleted'
45
+ print_group_and_members(res.body)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,39 @@
1
+ module Bl
2
+ class Notifications < Thor
3
+ include Bl::Requestable
4
+
5
+ def initialize(*)
6
+ @config = Bl::Config.instance
7
+ @url = 'notifications'
8
+ super
9
+ end
10
+
11
+ desc 'list', ''
12
+ options minId: :numeric, maxId: :numeric, count: :numeric, order: :string
13
+ def list
14
+ res = client.get(@url, options.to_h)
15
+ res.body.map { |n| puts n.pretty_inspect }
16
+ end
17
+
18
+ desc 'count', ''
19
+ options alreadyRead: :boolean, resourceAlreadyRead: :boolean
20
+ def count
21
+ # puts client.get("#{@url}/count").body.count
22
+ # TODO fix nil error
23
+ end
24
+
25
+ desc 'mark-as-read', ''
26
+ def mark_as_read
27
+ res = client.post("#{@url}/markAsRead")
28
+ puts 'notifications mark as readed'
29
+ puts res.body.count
30
+ end
31
+
32
+ desc 'read NOTIFICATIONS_ID', ''
33
+ def read(id)
34
+ res = client.post("#{@url}/#{id}/markAsRead")
35
+ puts "notifications #{id} readed"
36
+ puts res.pretty_inspect
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,86 @@
1
+ module Bl
2
+ class Users < Thor
3
+ include Bl::Requestable
4
+ include Bl::Formatting
5
+
6
+ def initialize(*)
7
+ @config = Bl::Config.instance
8
+ @url = 'users'
9
+ super
10
+ end
11
+
12
+ desc 'list', 'list users'
13
+ def list
14
+ client.get('users').body.map { |u| print_user(u) }
15
+ end
16
+
17
+ desc 'show USER_ID', ''
18
+ def show(id)
19
+ res = client.get("#{@url}/#{id}")
20
+ print_user(res.body)
21
+ end
22
+
23
+ desc 'add USER_ID PASSWORD NAME MAIL_ADDRESS ROLE_TYPE', ''
24
+ def add(id, pass, name, mail_address, role_type)
25
+ res = client.post("#{@url}", userId: id, password: pass, name: name, mailAddress: mail_address, roleType: role_type)
26
+ print_user(res.body)
27
+ end
28
+
29
+ USER_PARAMS = {
30
+ password: :string,
31
+ name: :string,
32
+ mailAddress: :string,
33
+ roleType: :numeric
34
+ }
35
+ desc 'update USER_ID', ''
36
+ options USER_PARAMS
37
+ def update(id)
38
+ res = client.patch("#{@url}/#{id}", options.to_h)
39
+ puts 'user updated:'
40
+ print_user(res.body)
41
+ end
42
+
43
+ desc 'delete', ''
44
+ def delete(id)
45
+ res = client.delete("#{@url}/#{id}")
46
+ puts 'user deleted'
47
+ print_user(res.body)
48
+ end
49
+
50
+ desc 'myself', ''
51
+ def myself
52
+ res = client.get("#{@url}/myself")
53
+ print_user(res.body)
54
+ end
55
+
56
+ desc 'icon ID', ''
57
+ def icon(id)
58
+ # res = client.get("#{@url}/#{id}/icon")
59
+ # TODO fix nil error
60
+ end
61
+
62
+ desc 'activities USER_ID', "list user's activities"
63
+ options activityTypeId: :array, minId: :numeric, maxId: :numeric, count: :numeric, order: :string
64
+ def activities(user_id)
65
+ res = client.get("/users/#{user_id}/activities")
66
+ res.body.map { |a| print_activity(a) }
67
+ end
68
+
69
+ desc 'stars [USER_ID...]', ''
70
+ options minId: :numeric, maxId: :numeric, count: :numeric, order: :string
71
+ def stars(*user_ids)
72
+ user_ids.each do |user_id|
73
+ res = client.get("/users/#{user_id}/stars", options.to_h)
74
+ res.body.map { |s| p s }
75
+ end
76
+ end
77
+
78
+ desc 'stars-count [USER_ID...]', "count user's stars"
79
+ options since: :string, until: :string
80
+ def stars_count(*user_ids)
81
+ user_ids.each do |user_id|
82
+ p client.get("/users/#{user_id}/stars/count", options.to_h).body.count
83
+ end
84
+ end
85
+ end
86
+ end
@@ -1,3 +1,3 @@
1
1
  module Bl
2
- VERSION = '0.3.1'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
@@ -0,0 +1,77 @@
1
+ module Bl
2
+ class Watchings < Thor
3
+ include Bl::Requestable
4
+ include Bl::Formatting
5
+
6
+ WATCHINGS_PARAMS = {
7
+ order: :string,
8
+ sort: :string,
9
+ count: :numeric,
10
+ offset: :numeric,
11
+ resourceAlreadyRead: :boolean,
12
+ issueId: :array
13
+ }
14
+
15
+ def initialize(*)
16
+ @config = Bl::Config.instance
17
+ @url = 'watchings'
18
+ super
19
+ end
20
+
21
+ desc 'list USER_ID', ''
22
+ options WATCHINGS_PARAMS
23
+ def list(id)
24
+ res = client.get("/users/#{id}/#{@url}", options.to_h)
25
+ res.body.map { |t| print_watch_target(t) }
26
+ end
27
+
28
+ desc 'count USER_ID', ''
29
+ options resourceAlreadyRead: :boolean, alreadyRead: :boolean
30
+ def count(id)
31
+ res = client.get("/users/#{id}/#{@url}/count")
32
+ puts res.body.count
33
+ end
34
+
35
+ desc 'show WATCHING_ID', ''
36
+ def show(id)
37
+ res = client.get("watchings/#{id}")
38
+ print_watch_target(res.body)
39
+ end
40
+
41
+ desc 'add', ''
42
+ options issueIdOrKey: :required, note: :string
43
+ def add
44
+ res = client.post('watchings', options.to_h)
45
+ puts 'watch added'
46
+ print_watch_target(res.body)
47
+ end
48
+
49
+ desc 'update WATCHING_ID', ''
50
+ option note: :string
51
+ def update(id)
52
+ # TODO fix conflict with issue update command
53
+ # res = client.patch("watchings/#{id}", option.to_h)
54
+ # puts 'watch updated'
55
+ # print_watch_target(res.body)
56
+ end
57
+
58
+ desc 'delete WATCHING_ID', ''
59
+ def delete(id)
60
+ res = client.delete("watchings/#{id}")
61
+ puts 'watch deleted'
62
+ print_watch_target(res.body)
63
+ end
64
+
65
+ desc 'mark-as-read WATCHING_ID', ''
66
+ def mark_as_read(id)
67
+ res = client.post("watchings/#{id}/markAsRead")
68
+ puts 'watch mark as read'
69
+ end
70
+
71
+ desc 'mark-as-checked USER_ID', ''
72
+ def mark_as_checked(id)
73
+ res = client.post("/users/#{id}/watchings/markAsChecked")
74
+ puts 'watch mark as checked'
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,55 @@
1
+ module Bl
2
+ class Webhooks < Thor
3
+ include Bl::Requestable
4
+ include Bl::Formatting
5
+
6
+ WEBHOOK_PARAMS = {
7
+ name: :string,
8
+ description: :string,
9
+ hookUrl: :string,
10
+ allEvent: :boolean,
11
+ activityTypeIds: :array
12
+ }
13
+
14
+ def initialize(*)
15
+ @config = Bl::Config.instance
16
+ @url = "projects/#{@config[:project_key]}/webhooks"
17
+ super
18
+ end
19
+
20
+ desc 'list', ''
21
+ def list
22
+ res = client.get(@url)
23
+ res.body.map { |w| print_webhook(w) }
24
+ end
25
+
26
+ desc 'show WEBHOOK_ID', ''
27
+ def show(id)
28
+ res = client.get("#{@url}/#{id}")
29
+ print_webhook(res.body)
30
+ end
31
+
32
+ desc 'add', ''
33
+ options WEBHOOK_PARAMS
34
+ def add
35
+ res = client.post(@url, options.to_h)
36
+ puts 'webhook added'
37
+ print_webhook(res.body)
38
+ end
39
+
40
+ desc 'update WEBHOOK_ID', ''
41
+ options WEBHOOK_PARAMS
42
+ def update(id)
43
+ res = client.patch("#{@url}/#{id}", options.to_h)
44
+ puts 'webhook updated'
45
+ print_webhook(res.body)
46
+ end
47
+
48
+ desc 'delete WEBHOOK_ID', ''
49
+ def delete(id)
50
+ res = client.delete("#{@url}/#{id}")
51
+ puts 'webhook deleted'
52
+ print_webhook(res.body)
53
+ end
54
+ end
55
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - saki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-01 00:00:00.000000000 Z
11
+ date: 2017-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -147,13 +147,18 @@ files:
147
147
  - lib/bl/file.rb
148
148
  - lib/bl/formatting.rb
149
149
  - lib/bl/gitrepo.rb
150
+ - lib/bl/groups.rb
150
151
  - lib/bl/milestone.rb
152
+ - lib/bl/notifications.rb
151
153
  - lib/bl/project.rb
152
154
  - lib/bl/recent.rb
153
155
  - lib/bl/requestable.rb
154
156
  - lib/bl/space.rb
155
157
  - lib/bl/type.rb
158
+ - lib/bl/users.rb
156
159
  - lib/bl/version.rb
160
+ - lib/bl/watchings.rb
161
+ - lib/bl/webhooks.rb
157
162
  - lib/bl/wiki.rb
158
163
  homepage: https://github.com/sakihet/bl
159
164
  licenses:
@@ -175,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
180
  version: '0'
176
181
  requirements: []
177
182
  rubyforge_project:
178
- rubygems_version: 2.5.1
183
+ rubygems_version: 2.6.11
179
184
  signing_key:
180
185
  specification_version: 4
181
186
  summary: bl is a command line tool for Backlog.