bl 0.6.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +5 -2
- data/README.md +32 -32
- data/Rakefile +4 -10
- data/bl.gemspec +5 -5
- data/etc/help.md +32 -31
- data/lib/bl.rb +16 -16
- data/lib/bl/cli.rb +25 -113
- data/lib/bl/command.rb +0 -1
- data/lib/bl/commands/category.rb +46 -0
- data/lib/bl/commands/file.rb +28 -0
- data/lib/bl/commands/gitrepo.rb +23 -0
- data/lib/bl/commands/group.rb +47 -0
- data/lib/bl/commands/issue.rb +104 -0
- data/lib/bl/commands/milestone.rb +60 -0
- data/lib/bl/commands/notification.rb +41 -0
- data/lib/bl/commands/project.rb +127 -0
- data/lib/bl/commands/pull_request.rb +23 -0
- data/lib/bl/commands/recent.rb +28 -0
- data/lib/bl/commands/space.rb +66 -0
- data/lib/bl/commands/type.rb +57 -0
- data/lib/bl/commands/user.rb +90 -0
- data/lib/bl/commands/watching.rb +67 -0
- data/lib/bl/commands/webhook.rb +52 -0
- data/lib/bl/commands/wiki.rb +79 -0
- data/lib/bl/version.rb +11 -1
- metadata +43 -43
- data/lib/bl/category.rb +0 -44
- data/lib/bl/file.rb +0 -26
- data/lib/bl/formatting.rb +0 -38
- data/lib/bl/gitrepo.rb +0 -22
- data/lib/bl/groups.rb +0 -45
- data/lib/bl/milestone.rb +0 -58
- data/lib/bl/notifications.rb +0 -38
- data/lib/bl/project.rb +0 -121
- data/lib/bl/pull_request.rb +0 -21
- data/lib/bl/recent.rb +0 -24
- data/lib/bl/space.rb +0 -61
- data/lib/bl/type.rb +0 -55
- data/lib/bl/users.rb +0 -87
- data/lib/bl/watchings.rb +0 -67
- data/lib/bl/webhooks.rb +0 -51
- data/lib/bl/wiki.rb +0 -77
data/lib/bl/notifications.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
module Bl
|
2
|
-
class Notifications < Command
|
3
|
-
|
4
|
-
def initialize(*)
|
5
|
-
@config = Bl::Config.instance
|
6
|
-
@url = 'notifications'
|
7
|
-
super
|
8
|
-
end
|
9
|
-
|
10
|
-
desc 'list', ''
|
11
|
-
options minId: :numeric, maxId: :numeric, count: :numeric, order: :string
|
12
|
-
def list
|
13
|
-
res = request(:get, @url, options.to_h)
|
14
|
-
res.body.map { |n| puts n.pretty_inspect }
|
15
|
-
end
|
16
|
-
|
17
|
-
desc 'count', ''
|
18
|
-
options alreadyRead: :boolean, resourceAlreadyRead: :boolean
|
19
|
-
def count
|
20
|
-
# puts request(:get, "#{@url}/count").body.count
|
21
|
-
# TODO fix nil error
|
22
|
-
end
|
23
|
-
|
24
|
-
desc 'mark-as-read', ''
|
25
|
-
def mark_as_read
|
26
|
-
res = request(:post, "#{@url}/markAsRead")
|
27
|
-
puts 'notifications mark as readed'
|
28
|
-
puts res.body.count
|
29
|
-
end
|
30
|
-
|
31
|
-
desc 'read NOTIFICATIONS_ID', ''
|
32
|
-
def read(id)
|
33
|
-
res = request(:post, "#{@url}/#{id}/markAsRead")
|
34
|
-
puts "notifications #{id} readed"
|
35
|
-
puts res.pretty_inspect
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
data/lib/bl/project.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
module Bl
|
2
|
-
class Project < Command
|
3
|
-
def initialize(*)
|
4
|
-
@config = Bl::Config.instance
|
5
|
-
@url = 'projects'
|
6
|
-
super
|
7
|
-
end
|
8
|
-
|
9
|
-
desc 'activities ID', 'show project activities'
|
10
|
-
def activities(id)
|
11
|
-
res = request(:get, "#{@url}/#{id}/activities")
|
12
|
-
res.body.each do |a|
|
13
|
-
p a.pretty_inspect
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
desc 'list', 'list projects'
|
18
|
-
def list
|
19
|
-
res = request(:get, @url)
|
20
|
-
print_response(res, :project)
|
21
|
-
end
|
22
|
-
|
23
|
-
desc 'show', 'show project'
|
24
|
-
def show(id)
|
25
|
-
res = request(:get, "#{@url}/#{id}")
|
26
|
-
print_response(res, :project)
|
27
|
-
rescue => e
|
28
|
-
puts e.message
|
29
|
-
end
|
30
|
-
|
31
|
-
desc 'add', 'add project'
|
32
|
-
option :key, required: true, type: :string
|
33
|
-
option :chartEnabled, type: :boolean, default: false
|
34
|
-
option :projectLeaderCanEditProjectLeader, type: :boolean, default: false
|
35
|
-
option :subtaskingEnabled, type: :boolean, default: false
|
36
|
-
option :textFormattingRule, type: :string, default: 'markdown'
|
37
|
-
def add(name)
|
38
|
-
res = request(:post, @url, {name: name}.merge(delete_class_options(options.to_h)))
|
39
|
-
puts 'project added'
|
40
|
-
print_response(res, :project)
|
41
|
-
end
|
42
|
-
|
43
|
-
desc 'update', 'update project'
|
44
|
-
options PROJECT_PARAMS
|
45
|
-
def update(id)
|
46
|
-
res = request(:patch, "#{@url}/#{id}", delete_class_options(options.to_h))
|
47
|
-
puts 'project updated'
|
48
|
-
print_response(res, :project)
|
49
|
-
end
|
50
|
-
|
51
|
-
desc 'delete', 'delete project'
|
52
|
-
def delete(id)
|
53
|
-
res = request(:delete, "#{@url}/#{id}")
|
54
|
-
puts 'project deleted'
|
55
|
-
print_response(res, :project)
|
56
|
-
end
|
57
|
-
|
58
|
-
desc 'status ID', 'show project status'
|
59
|
-
def status(id)
|
60
|
-
all_issues_count = count_issues(id)
|
61
|
-
open_issues_count = count_issues(id, statusId: [1])
|
62
|
-
in_progress_issues_count = count_issues(id, statusId: [2])
|
63
|
-
resolved_issues_count = count_issues(id, statusId: [3])
|
64
|
-
closed_issues_count = count_issues(id, statusId: [4])
|
65
|
-
puts "#{closed_issues_count} / #{all_issues_count}"
|
66
|
-
puts "open: #{open_issues_count}"
|
67
|
-
puts "in progress: #{in_progress_issues_count}"
|
68
|
-
puts "resolved: #{resolved_issues_count}"
|
69
|
-
puts "closed: #{closed_issues_count}"
|
70
|
-
end
|
71
|
-
|
72
|
-
desc 'progress ID', 'show project progress'
|
73
|
-
def progress(id)
|
74
|
-
puts '--status--'
|
75
|
-
all_issues_count = count_issues(id)
|
76
|
-
closed_issues_count = count_issues(id, statusId: [4])
|
77
|
-
puts "#{closed_issues_count} / #{all_issues_count}"
|
78
|
-
puts '--milestone--'
|
79
|
-
versions = request(:get, "projects/#{@config[:project_key]}/versions").body
|
80
|
-
versions.each do |version|
|
81
|
-
all_issues_count = count_issues(id, milestoneId: [version.id])
|
82
|
-
closed_issues_count = count_issues(id, milestoneId: [version.id], statusId: [4])
|
83
|
-
puts "#{version.name}: #{closed_issues_count} / #{all_issues_count}"
|
84
|
-
end
|
85
|
-
puts '--category--'
|
86
|
-
categories = request(:get, "projects/#{@config[:project_key]}/categories").body
|
87
|
-
categories.each do |category|
|
88
|
-
all_issues_count = count_issues(id, categoryId: [category.id])
|
89
|
-
closed_issues_count = count_issues(id, categoryId: [category.id], statusId: [4])
|
90
|
-
puts "#{category.name}: #{closed_issues_count} / #{all_issues_count}"
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
desc 'users ID', 'show project users'
|
95
|
-
def users(id)
|
96
|
-
res = request(:get, "#{@url}/#{id}/users")
|
97
|
-
puts formatter.render(res.body, fields: USER_FIELDS)
|
98
|
-
end
|
99
|
-
|
100
|
-
desc 'image ID', 'get project image file'
|
101
|
-
def image(id)
|
102
|
-
res = request(:get, "#{@url}/#{id}/image")
|
103
|
-
::File.open(res.body.filename, 'wb') { |f| f.write(res.body.content) }
|
104
|
-
puts "#{res.body.filename} generated"
|
105
|
-
end
|
106
|
-
|
107
|
-
private
|
108
|
-
|
109
|
-
def count_issues(project_id, args={})
|
110
|
-
args = {
|
111
|
-
projectId: [project_id],
|
112
|
-
}.merge(args)
|
113
|
-
request(
|
114
|
-
:get,
|
115
|
-
'issues/count',
|
116
|
-
args
|
117
|
-
).body.count
|
118
|
-
end
|
119
|
-
|
120
|
-
end
|
121
|
-
end
|
data/lib/bl/pull_request.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Bl
|
2
|
-
class PullRequest < Command
|
3
|
-
def initialize(*)
|
4
|
-
@config = Bl::Config.instance
|
5
|
-
@url = "projects/#{@config[:project_key]}/git/repositories"
|
6
|
-
super
|
7
|
-
end
|
8
|
-
|
9
|
-
desc 'count ID', 'count pull requests'
|
10
|
-
def count(id)
|
11
|
-
res = request(:get, "#{@url}/#{id}/pullRequests/count")
|
12
|
-
puts res.body.count
|
13
|
-
end
|
14
|
-
|
15
|
-
desc 'list ID', 'list pull requests'
|
16
|
-
def list(id)
|
17
|
-
res = request(:get, "#{@url}/#{id}/pullRequests")
|
18
|
-
print_response(res, :pull_request)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/bl/recent.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module Bl
|
2
|
-
class Recent < Command
|
3
|
-
def initialize(*)
|
4
|
-
@config = Bl::Config.instance
|
5
|
-
super
|
6
|
-
end
|
7
|
-
|
8
|
-
desc 'issues COUNT', 'list recently viewed issues'
|
9
|
-
def issues(count = nil)
|
10
|
-
res = request(:get, 'users/myself/recentlyViewedIssues', count: count)
|
11
|
-
res.body.each do |i|
|
12
|
-
puts [i.issue.issueKey, i.issue.summary].join("\t")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
desc 'wikis COUNT', 'list recently viewed wikis'
|
17
|
-
def wikis(count = nil)
|
18
|
-
res = request(:get, 'users/myself/recentlyViewedWikis', count: count)
|
19
|
-
res.body.each do |w|
|
20
|
-
puts [w.page.id, w.page.name].join("\t")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/lib/bl/space.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
module Bl
|
2
|
-
class Space < Command
|
3
|
-
|
4
|
-
def initialize(*)
|
5
|
-
@config = Bl::Config.instance
|
6
|
-
super
|
7
|
-
end
|
8
|
-
|
9
|
-
desc 'info', 'show space info'
|
10
|
-
def info
|
11
|
-
res = request(:get, 'space')
|
12
|
-
puts formatter.render(res.body, fields: SPACE_FIELDS)
|
13
|
-
end
|
14
|
-
|
15
|
-
desc 'activities', 'show space activities'
|
16
|
-
def activities
|
17
|
-
request(:get, 'space/activities').body.each do |a|
|
18
|
-
p a.pretty_inspect
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
desc 'image', 'get space image file'
|
23
|
-
def image
|
24
|
-
body = request(:get, 'space/image').body
|
25
|
-
::File.open(body.filename, "wb") {|f| f.write(body.content)}
|
26
|
-
puts "#{body.filename} generated."
|
27
|
-
end
|
28
|
-
|
29
|
-
desc 'get-notification', 'get space notification'
|
30
|
-
def get_notification
|
31
|
-
res = request(:get, 'space/notification')
|
32
|
-
print_space_notification(res)
|
33
|
-
end
|
34
|
-
|
35
|
-
desc 'update-notification CONTENT', 'update space notification'
|
36
|
-
def update_notification(content)
|
37
|
-
res = client.put('space/notification', content: content)
|
38
|
-
puts 'space notification updated'
|
39
|
-
print_space_notification(res)
|
40
|
-
end
|
41
|
-
|
42
|
-
desc 'disk-usage', 'get space disk usage'
|
43
|
-
def disk_usage
|
44
|
-
res = request(:get, 'space/diskUsage')
|
45
|
-
print_space_disk_usage(res)
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def print_space_notification(res)
|
51
|
-
puts formatter.render(res.body, fields: SPACE_NOTIFICATION_FIELDS)
|
52
|
-
end
|
53
|
-
|
54
|
-
def print_space_disk_usage(res)
|
55
|
-
puts 'summary:'
|
56
|
-
puts formatter.render(res.body, fields: SPACE_DISK_USAGE)
|
57
|
-
puts 'details:'
|
58
|
-
res.body.details.map { |v| puts formatter.render(v, fields: SPACE_DISK_USAGE_DETAILS_FIELDS) }
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
data/lib/bl/type.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
module Bl
|
2
|
-
class Type < Command
|
3
|
-
def initialize(*)
|
4
|
-
@config = Bl::Config.instance
|
5
|
-
@url = "projects/#{@config[:project_key]}/issueTypes"
|
6
|
-
super
|
7
|
-
end
|
8
|
-
|
9
|
-
desc 'list', 'list issue types'
|
10
|
-
def list
|
11
|
-
res = request(:get, @url)
|
12
|
-
puts 'types:'
|
13
|
-
print_response(res, :type)
|
14
|
-
end
|
15
|
-
|
16
|
-
desc 'add [NAME...]', 'add types'
|
17
|
-
option :color, type: :string, required: true
|
18
|
-
def add(*names)
|
19
|
-
names.each do |name|
|
20
|
-
res = request(:post, @url, name: name, color: options[:color])
|
21
|
-
puts 'type added'
|
22
|
-
print_response(res, :type)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
desc 'update [ID...]', 'update types'
|
27
|
-
option :name, type: :string
|
28
|
-
option :color, color: :color
|
29
|
-
def update(*ids)
|
30
|
-
ids.each do |id|
|
31
|
-
res = request(:patch, "#{@url}/#{id}", delete_class_options(options))
|
32
|
-
puts 'type updated'
|
33
|
-
print_response(res, :type)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
desc 'delete [ID...]', 'delete types'
|
38
|
-
option :substituteIssueTypeId, type: :numeric, required: true
|
39
|
-
def delete(*ids)
|
40
|
-
ids.each do |id|
|
41
|
-
res = request(:delete, "#{@url}/#{id}", delete_class_options(options))
|
42
|
-
puts 'type deleted'
|
43
|
-
print_response(res, :type)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
desc 'colors', 'list available colors'
|
48
|
-
def colors
|
49
|
-
puts 'colors:'
|
50
|
-
TYPE_COLORS.each do |color|
|
51
|
-
puts Paint[color, '#ffffff', color]
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
data/lib/bl/users.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
module Bl
|
2
|
-
class Users < Command
|
3
|
-
def initialize(*)
|
4
|
-
@config = Bl::Config.instance
|
5
|
-
@url = 'users'
|
6
|
-
super
|
7
|
-
end
|
8
|
-
|
9
|
-
desc 'list', 'list users'
|
10
|
-
def list
|
11
|
-
res = request(:get, 'users')
|
12
|
-
print_response(res, :user)
|
13
|
-
end
|
14
|
-
|
15
|
-
desc 'show USER_ID', ''
|
16
|
-
def show(id)
|
17
|
-
res = request(:get, "#{@url}/#{id}")
|
18
|
-
puts formatter.render(res.body, fields: USER_FIELDS)
|
19
|
-
end
|
20
|
-
|
21
|
-
desc 'add USER_ID PASSWORD NAME MAIL_ADDRESS ROLE_TYPE', ''
|
22
|
-
def add(id, pass, name, mail_address, role_type)
|
23
|
-
res = request(
|
24
|
-
:post,
|
25
|
-
@url,
|
26
|
-
userId: id,
|
27
|
-
password: pass,
|
28
|
-
name: name,
|
29
|
-
mailAddress: mail_address,
|
30
|
-
roleType: role_type
|
31
|
-
)
|
32
|
-
puts 'user added'
|
33
|
-
print_response(res, :user)
|
34
|
-
end
|
35
|
-
|
36
|
-
desc 'update USER_ID', ''
|
37
|
-
options USER_PARAMS
|
38
|
-
def update(id)
|
39
|
-
res = request(:patch, "#{@url}/#{id}", delete_class_options(options.to_h))
|
40
|
-
puts 'user updated:'
|
41
|
-
print_response(res, :user)
|
42
|
-
end
|
43
|
-
|
44
|
-
desc 'delete', ''
|
45
|
-
def delete(id)
|
46
|
-
res = request(:delete, "#{@url}/#{id}")
|
47
|
-
puts 'user deleted'
|
48
|
-
print_response(res, :user)
|
49
|
-
end
|
50
|
-
|
51
|
-
desc 'myself', ''
|
52
|
-
def myself
|
53
|
-
res = request(:get, "#{@url}/myself")
|
54
|
-
print_response(res, :user)
|
55
|
-
end
|
56
|
-
|
57
|
-
desc 'icon ID', ''
|
58
|
-
def icon(id)
|
59
|
-
# res = request(:get, "#{@url}/#{id}/icon")
|
60
|
-
# TODO fix nil error
|
61
|
-
end
|
62
|
-
|
63
|
-
desc 'activities USER_ID', "list user's activities"
|
64
|
-
options activityTypeId: :array, minId: :numeric, maxId: :numeric, count: :numeric, order: :string
|
65
|
-
def activities(user_id)
|
66
|
-
res = request(:get, "/users/#{user_id}/activities")
|
67
|
-
res.body.map { |a| print_activity(a) }
|
68
|
-
end
|
69
|
-
|
70
|
-
desc 'stars [USER_ID...]', ''
|
71
|
-
options minId: :numeric, maxId: :numeric, count: :numeric, order: :string
|
72
|
-
def stars(*user_ids)
|
73
|
-
user_ids.each do |user_id|
|
74
|
-
res = request(:get, "/users/#{user_id}/stars", options.to_h)
|
75
|
-
res.body.map { |s| p s }
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
desc 'stars-count [USER_ID...]', "count user's stars"
|
80
|
-
options since: :string, until: :string
|
81
|
-
def stars_count(*user_ids)
|
82
|
-
user_ids.each do |user_id|
|
83
|
-
p request(:get, "/users/#{user_id}/stars/count", options.to_h).body.count
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
data/lib/bl/watchings.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
module Bl
|
2
|
-
class Watchings < Command
|
3
|
-
|
4
|
-
def initialize(*)
|
5
|
-
@config = Bl::Config.instance
|
6
|
-
@url = 'watchings'
|
7
|
-
super
|
8
|
-
end
|
9
|
-
|
10
|
-
desc 'list USER_ID', ''
|
11
|
-
options WATCHINGS_PARAMS
|
12
|
-
def list(id)
|
13
|
-
res = request(:get, "/users/#{id}/#{@url}", delete_class_options(options.to_h))
|
14
|
-
res.body.map { |t| print_watch_target(t) }
|
15
|
-
end
|
16
|
-
|
17
|
-
desc 'count USER_ID', ''
|
18
|
-
options resourceAlreadyRead: :boolean, alreadyRead: :boolean
|
19
|
-
def count(id)
|
20
|
-
res = request(:get, "/users/#{id}/#{@url}/count")
|
21
|
-
puts res.body.count
|
22
|
-
end
|
23
|
-
|
24
|
-
desc 'show WATCHING_ID', ''
|
25
|
-
def show(id)
|
26
|
-
res = request(:get, "watchings/#{id}")
|
27
|
-
print_watch_target(res.body)
|
28
|
-
end
|
29
|
-
|
30
|
-
desc 'add', ''
|
31
|
-
options issueIdOrKey: :required, note: :string
|
32
|
-
def add
|
33
|
-
res = request(:post, 'watchings', options.to_h)
|
34
|
-
puts 'watch added'
|
35
|
-
print_watch_target(res.body)
|
36
|
-
end
|
37
|
-
|
38
|
-
desc 'update WATCHING_ID', ''
|
39
|
-
option note: :string
|
40
|
-
def update(id)
|
41
|
-
# TODO fix conflict with issue update command
|
42
|
-
# res = request(:patch, "watchings/#{id}", option.to_h)
|
43
|
-
# puts 'watch updated'
|
44
|
-
# print_watch_target(res.body)
|
45
|
-
end
|
46
|
-
|
47
|
-
desc 'delete WATCHING_ID', ''
|
48
|
-
def delete(id)
|
49
|
-
res = request(:delete, "watchings/#{id}")
|
50
|
-
puts 'watch deleted'
|
51
|
-
print_watch_target(res.body)
|
52
|
-
end
|
53
|
-
|
54
|
-
desc 'mark-as-read WATCHING_ID', ''
|
55
|
-
def mark_as_read(id)
|
56
|
-
res = request(:post, "watchings/#{id}/markAsRead")
|
57
|
-
puts 'watch mark as read'
|
58
|
-
end
|
59
|
-
|
60
|
-
desc 'mark-as-checked USER_ID', ''
|
61
|
-
def mark_as_checked(id)
|
62
|
-
res = request(:post, "/users/#{id}/watchings/markAsChecked")
|
63
|
-
puts 'watch mark as checked'
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|