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.
@@ -1,51 +0,0 @@
1
- module Bl
2
- class Webhooks < Command
3
-
4
- def initialize(*)
5
- @config = Bl::Config.instance
6
- @url = "projects/#{@config[:project_key]}/webhooks"
7
- super
8
- end
9
-
10
- desc 'list', ''
11
- def list
12
- res = request(:get, @url)
13
- print_response(res)
14
- end
15
-
16
- desc 'show WEBHOOK_ID', ''
17
- def show(id)
18
- res = request(:get, "#{@url}/#{id}")
19
- print_response(res)
20
- end
21
-
22
- desc 'add', ''
23
- options WEBHOOK_PARAMS
24
- def add
25
- res = request(:post, @url, options.to_h)
26
- puts 'webhook added'
27
- print_response(res)
28
- end
29
-
30
- desc 'update WEBHOOK_ID', ''
31
- options WEBHOOK_PARAMS
32
- def update(id)
33
- res = request(:patch, "#{@url}/#{id}", options.to_h)
34
- puts 'webhook updated'
35
- print_response(res)
36
- end
37
-
38
- desc 'delete WEBHOOK_ID', ''
39
- def delete(id)
40
- res = request(:delete, "#{@url}/#{id}")
41
- puts 'webhook deleted'
42
- print_response(res)
43
- end
44
-
45
- private
46
-
47
- def print_response(res)
48
- puts formatter.render(res.body, fields: WEBHOOK_FIELDS)
49
- end
50
- end
51
- end
@@ -1,77 +0,0 @@
1
- module Bl
2
- class Wiki < Command
3
- def initialize(*)
4
- @config = Bl::Config.instance
5
- @url = 'wikis'
6
- super
7
- end
8
-
9
- desc 'add NAME', 'add wiki'
10
- option :projectId, type: :numeric, required: true
11
- option :content, type: :string, required: true
12
- def add(name)
13
- res = request(
14
- :post,
15
- @url,
16
- projectId: options[:projectId],
17
- name: name,
18
- content: options[:content]
19
- )
20
- puts 'wiki added:'
21
- print_response(res, :wiki)
22
- end
23
-
24
- desc 'count', 'count wiki'
25
- option :projectIdOrKey, type: :numeric, required: true
26
- def count
27
- res = request(:get, "#{@url}/count", projectIdOrKey: options[:projectIdOrKey])
28
- puts 'wiki count'
29
- puts res.body.count
30
- end
31
-
32
- desc 'delete ID', 'delete wiki'
33
- def delete(id)
34
- res = request(:delete, "#{@url}/#{id}")
35
- puts 'wiki deleted'
36
- print_response(res, :wiki)
37
- end
38
-
39
- desc 'list', 'list wikis'
40
- def list
41
- res = request(:get, @url, projectIdOrKey: @config[:project_key])
42
- print_response(res, :wiki)
43
- end
44
-
45
- desc 'show ID', "show a wiki's content"
46
- def show(id)
47
- res = request(:get, "#{@url}/#{id}")
48
- puts formatter.render(res.body, fields: WIKI_FIELDS.push(:content), vertical: true)
49
- end
50
-
51
- desc 'tags', 'show wiki tags'
52
- option :projectIdOrKey, type: :numeric, required: true
53
- def tags
54
- res = request(:get, "#{@url}/tags", projectIdOrKey: options[:projectIdOrKey])
55
- puts 'wiki tags:'
56
- print_response(res, :named)
57
- end
58
-
59
- desc 'edit ID', 'edit a wiki by $EDITOR'
60
- def edit(id)
61
- wiki_content = request(:get, "#{@url}/#{id}").body.content
62
- file = Tempfile.new
63
- file.puts(wiki_content)
64
- file.close
65
- begin
66
- file.open
67
- system("$EDITOR #{file.path}")
68
- new_content = file.read
69
- request(:patch, "#{@url}/#{id}", content: new_content)
70
- puts "wiki #{id} updated."
71
- ensure
72
- file.close
73
- file.unlink
74
- end
75
- end
76
- end
77
- end