terjira 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +3 -0
- data/bin/terjira +2 -1
- data/lib/terjira/issue_cli.rb +3 -3
- data/lib/terjira/option_support/editor.rb +22 -0
- data/lib/terjira/option_support/option_selector.rb +53 -13
- data/lib/terjira/option_support/shared_options.rb +4 -0
- data/lib/terjira/option_supportable.rb +1 -0
- data/lib/terjira/version.rb +1 -1
- data/terjira.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81619376a1f94486a87bad473155828c7df19ffb
|
4
|
+
data.tar.gz: cb695455adb913a7a34f62f4aac32e09786132b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92ccea746712cc915a5b77785a1a960deb9e7ad5a8f839ded15ceaa3819ebb818987b69d5897f05806fb2d09845706e3e2dcf7efd41ec2436745a44243d1df10
|
7
|
+
data.tar.gz: e72c0f6b9efbfe35161bbaf139ef598d2a824a8e101d75c3493ec5dc30635b8da62d8768e836adfc828094175acdcbf6cb596d8c0ba7eaffdd3f450e1fc1281e
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -70,9 +70,12 @@ Issue:
|
|
70
70
|
jira issue [ISSUE_KEY] # Show detail of the issue
|
71
71
|
jira issue assign [ISSUE_KEY] ([ASSIGNEE]) # Assign the issue to user
|
72
72
|
jira issue comment [ISSUE_KEY] # Write comment on the issue
|
73
|
+
# pass `-E` or `--editor` to open system default editor for composing comment
|
73
74
|
jira issue delete [ISSUE_KEY] # Delete the issue
|
74
75
|
jira issue edit [ISSUE_KEY] # Edit the issue
|
76
|
+
# pass `-E` or `--editor` to open system default editor for composing issue description
|
75
77
|
jira issue new # Create an issue
|
78
|
+
# pass `-E` or `--editor` to open system default editor for composing issue description
|
76
79
|
jira issue open [ISSUE_KEY] # Open browser
|
77
80
|
jira issue take [ISSUE_KEY] # Assign the issue to self
|
78
81
|
jira issue trans [ISSUE_KEY] ([STATUS]) # Do transition
|
data/bin/terjira
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Do I need bundler setup?
|
4
4
|
require 'bundler/setup'
|
5
|
-
|
5
|
+
require_relative '../lib/terjira'
|
6
6
|
require 'json'
|
7
7
|
require 'pastel'
|
8
8
|
|
@@ -19,5 +19,6 @@ rescue JIRA::HTTPError => e
|
|
19
19
|
puts pastel.red(message['errors'].map { |k, v| "#{k}: #{v}" }.join(", "))
|
20
20
|
end
|
21
21
|
rescue => e
|
22
|
+
puts e.backtrace
|
22
23
|
puts Pastel.new.dim(e.message)
|
23
24
|
end
|
data/lib/terjira/issue_cli.rb
CHANGED
@@ -53,7 +53,7 @@ module Terjira
|
|
53
53
|
|
54
54
|
desc 'new', 'Create an issue'
|
55
55
|
jira_options :summary, :description, :project, :issuetype,
|
56
|
-
:priority, :assignee, :parent, :epiclink
|
56
|
+
:priority, :assignee, :parent, :epiclink, :editor
|
57
57
|
def new
|
58
58
|
opts = suggest_options(required: [:project, :summary, :issuetype])
|
59
59
|
|
@@ -65,7 +65,7 @@ module Terjira
|
|
65
65
|
|
66
66
|
desc 'edit [ISSUE_KEY]', 'Edit the issue'
|
67
67
|
jira_options :summary, :description, :project, :issuetype,
|
68
|
-
:priority, :assignee, :epiclink
|
68
|
+
:priority, :assignee, :epiclink, :editor
|
69
69
|
def edit(issue)
|
70
70
|
return puts "Pass options you need to update" if options.blank?
|
71
71
|
issue = client_class.find(issue)
|
@@ -83,7 +83,7 @@ module Terjira
|
|
83
83
|
end
|
84
84
|
|
85
85
|
desc 'comment [ISSUE_KEY]', 'Write comment on the issue'
|
86
|
-
jira_options :comment
|
86
|
+
jira_options :comment, :editor
|
87
87
|
def comment(issue)
|
88
88
|
opts = suggest_options(required: [:comment])
|
89
89
|
issue = client_class.write_comment(issue, opts[:comment])
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Terjira
|
4
|
+
class Editor
|
5
|
+
def self.editor_text
|
6
|
+
editor = ENV['EDITOR']
|
7
|
+
if editor.nil? || editor.empty?
|
8
|
+
raise 'EDITOR environment variable not found. Please set a default editor.'
|
9
|
+
end
|
10
|
+
|
11
|
+
tmp_file = Tempfile.new('content')
|
12
|
+
success = system "#{editor} #{tmp_file.path}"
|
13
|
+
content = File.read(tmp_file.path) if success
|
14
|
+
|
15
|
+
tmp_file.unlink
|
16
|
+
|
17
|
+
raise 'Editor returned a non-zero exit code. Something must have gone wrong' unless success
|
18
|
+
|
19
|
+
content
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -2,15 +2,24 @@
|
|
2
2
|
|
3
3
|
require 'tty-prompt'
|
4
4
|
require_relative 'resource_store'
|
5
|
+
require_relative 'editor'
|
5
6
|
|
6
7
|
module Terjira
|
7
8
|
module OptionSelector
|
8
9
|
delegate :get, :set, :fetch, to: :resource_store
|
9
10
|
|
11
|
+
def with_editor=(with_editor = false)
|
12
|
+
@with_editor = with_editor
|
13
|
+
end
|
14
|
+
|
15
|
+
def with_editor?
|
16
|
+
@with_editor || false
|
17
|
+
end
|
18
|
+
|
10
19
|
def select_project
|
11
20
|
fetch :project do
|
12
21
|
projects = fetch(:projects) { Client::Project.all }
|
13
|
-
|
22
|
+
option_select_prompt.select('Choose project?', per_page: per_page(projects)) do |menu|
|
14
23
|
projects.each { |project| menu.choice project_choice_title(project), project }
|
15
24
|
end
|
16
25
|
end
|
@@ -19,7 +28,7 @@ module Terjira
|
|
19
28
|
def select_board(type = nil)
|
20
29
|
fetch(:board) do
|
21
30
|
boards = fetch(:boards) { Client::Board.all(type: type) }
|
22
|
-
|
31
|
+
option_select_prompt.select('Choose board?', per_page: per_page(boards)) do |menu|
|
23
32
|
boards.sort_by(&:id).each do |board|
|
24
33
|
menu.choice "#{board.key_value} - #{board.name}", board
|
25
34
|
end
|
@@ -31,7 +40,7 @@ module Terjira
|
|
31
40
|
fetch(:sprint) do
|
32
41
|
board = select_board('scrum')
|
33
42
|
sprints = fetch(:sprints) { Client::Sprint.all(board) }
|
34
|
-
|
43
|
+
option_select_prompt.select('Choose sprint?') do |menu|
|
35
44
|
sort_sprint_by_state(sprints).each do |sprint|
|
36
45
|
menu.choice sprint_choice_title(sprint), sprint
|
37
46
|
end
|
@@ -53,7 +62,7 @@ module Terjira
|
|
53
62
|
end
|
54
63
|
end
|
55
64
|
|
56
|
-
|
65
|
+
option_select_prompt.select('Choose assignee?', per_page: per_page(users)) do |menu|
|
57
66
|
users.each { |user| menu.choice user_choice_title(user), user }
|
58
67
|
end
|
59
68
|
end
|
@@ -68,7 +77,7 @@ module Terjira
|
|
68
77
|
set(:project, project)
|
69
78
|
end
|
70
79
|
|
71
|
-
|
80
|
+
option_select_prompt.select('Choose issue type?') do |menu|
|
72
81
|
project.issuetypes.each do |issuetype|
|
73
82
|
menu.choice issuetype.name, issuetype
|
74
83
|
end
|
@@ -91,7 +100,7 @@ module Terjira
|
|
91
100
|
Client::Status.all(project)
|
92
101
|
end
|
93
102
|
|
94
|
-
|
103
|
+
option_select_prompt.select('Choose status?') do |menu|
|
95
104
|
statuses.each do |status|
|
96
105
|
menu.choice status.name, status
|
97
106
|
end
|
@@ -102,7 +111,7 @@ module Terjira
|
|
102
111
|
def select_priority
|
103
112
|
fetch(:priority) do
|
104
113
|
priorities = fetch(:priorities) { Terjira::Client::Priority.all }
|
105
|
-
|
114
|
+
option_select_prompt.select('Choose priority?') do |menu|
|
106
115
|
priorities.each do |priority|
|
107
116
|
menu.choice priority.name, priority
|
108
117
|
end
|
@@ -113,7 +122,7 @@ module Terjira
|
|
113
122
|
def select_resolution
|
114
123
|
fetch(:resolution) do
|
115
124
|
resolutions = fetch(:resolutions) { Terjira::Client::Resolution.all }
|
116
|
-
|
125
|
+
option_select_prompt.select('Choose resolution?') do |menu|
|
117
126
|
resolutions.each do |resolution|
|
118
127
|
menu.choice resolution.name, resolution
|
119
128
|
end
|
@@ -133,15 +142,21 @@ module Terjira
|
|
133
142
|
|
134
143
|
def write_comment
|
135
144
|
fetch(:comment) do
|
136
|
-
|
137
|
-
|
145
|
+
if with_editor?
|
146
|
+
Editor.editor_text
|
147
|
+
else
|
148
|
+
prompt_multiline('Comment')
|
149
|
+
end
|
138
150
|
end
|
139
151
|
end
|
140
152
|
|
141
153
|
def write_description
|
142
154
|
fetch(:description) do
|
143
|
-
|
144
|
-
|
155
|
+
if with_editor?
|
156
|
+
Editor.editor_text
|
157
|
+
else
|
158
|
+
prompt_multiline('Description')
|
159
|
+
end
|
145
160
|
end
|
146
161
|
end
|
147
162
|
|
@@ -155,6 +170,11 @@ module Terjira
|
|
155
170
|
|
156
171
|
private
|
157
172
|
|
173
|
+
def prompt_multiline(prompt_for)
|
174
|
+
result = option_prompt.multiline("#{prompt_for}?")
|
175
|
+
result.join("") if result
|
176
|
+
end
|
177
|
+
|
158
178
|
def sprint_choice_title(sprint)
|
159
179
|
"#{sprint.key_value} - #{sprint.name} (#{sprint.state.capitalize})"
|
160
180
|
end
|
@@ -172,7 +192,27 @@ module Terjira
|
|
172
192
|
end
|
173
193
|
|
174
194
|
def option_prompt
|
175
|
-
@option_prompt ||= TTY::Prompt.new
|
195
|
+
@option_prompt ||= TTY::Prompt.new(help_color: :cyan)
|
196
|
+
end
|
197
|
+
|
198
|
+
def option_select_prompt
|
199
|
+
return @_option_select_prompt if @_option_select_prompt
|
200
|
+
@_option_select_prompt = TTY::Prompt.new(help_color: :cyan)
|
201
|
+
@_option_select_prompt.on(:keypress) do |event|
|
202
|
+
# emacs key binding
|
203
|
+
{ "\u000E" => :keydown, "\u0010" => :keyup }.each do |key, action|
|
204
|
+
if event.value == key
|
205
|
+
@_option_select_prompt.trigger(action)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
# vim key binding
|
209
|
+
{ 'j' => :keydown, 'k' => :keyup, 'h' => :keyleft, 'l' => :keyright }.each do |key, action|
|
210
|
+
if event.value == key
|
211
|
+
@_option_select_prompt.trigger(action)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
@_option_select_prompt
|
176
216
|
end
|
177
217
|
|
178
218
|
def per_page(objects)
|
data/lib/terjira/version.rb
CHANGED
data/terjira.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
23
|
spec.add_dependency "thor", "~> 0.19.0"
|
24
|
-
spec.add_dependency "jira-ruby", "
|
24
|
+
spec.add_dependency "jira-ruby", "1.1.3"
|
25
25
|
spec.add_dependency "activesupport", "4.0.13"
|
26
26
|
|
27
27
|
spec.add_dependency "tty-table", "~> 0.8.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terjira
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaehyun Shin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: jira-ruby
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.1.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.1.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -225,6 +225,7 @@ files:
|
|
225
225
|
- lib/terjira/client/user.rb
|
226
226
|
- lib/terjira/ext/jira_ruby.rb
|
227
227
|
- lib/terjira/issue_cli.rb
|
228
|
+
- lib/terjira/option_support/editor.rb
|
228
229
|
- lib/terjira/option_support/option_selector.rb
|
229
230
|
- lib/terjira/option_support/resource_store.rb
|
230
231
|
- lib/terjira/option_support/shared_options.rb
|