Skip to content

Commit

Permalink
FIXES use jira_options & change alternative param for editor to -E
Browse files Browse the repository at this point in the history
  • Loading branch information
kimpers committed Aug 28, 2017
1 parent a38f3bc commit d30c951
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ Issue:
jira issue [ISSUE_KEY] # Show detail of the issue
jira issue assign [ISSUE_KEY] ([ASSIGNEE]) # Assign the issue to user
jira issue comment [ISSUE_KEY] # Write comment on the issue
# pass `-e` or `--editor` to open system default editor for composing comment
# pass `-E` or `--editor` to open system default editor for composing comment
jira issue delete [ISSUE_KEY] # Delete the issue
jira issue edit [ISSUE_KEY] # Edit the issue
# pass `-e` or `--editor` to open system default editor for composing issue description
# pass `-E` or `--editor` to open system default editor for composing issue description
jira issue new # Create an issue
# pass `-e` or `--editor` to open system default editor for composing issue description
# pass `-E` or `--editor` to open system default editor for composing issue description
jira issue open [ISSUE_KEY] # Open browser
jira issue take [ISSUE_KEY] # Assign the issue to self
jira issue trans [ISSUE_KEY] ([STATUS]) # Do transition
Expand Down
27 changes: 10 additions & 17 deletions lib/terjira/issue_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def jql(*query)

desc 'new', 'Create an issue'
jira_options :summary, :description, :project, :issuetype,
:priority, :assignee, :parent, :epiclink
def new(*keys)
:priority, :assignee, :parent, :epiclink, :editor
def new
opts = suggest_options(required: [:project, :summary, :issuetype],
resources: { editor: use_editor(keys) })
resources: { editor: options.editor })

suggest_related_value_options(opts)

Expand All @@ -66,12 +66,11 @@ def new(*keys)

desc 'edit [ISSUE_KEY]', 'Edit the issue'
jira_options :summary, :description, :project, :issuetype,
:priority, :assignee, :epiclink
def edit(*keys)
issue = keys[0]
:priority, :assignee, :epiclink, :editor
def edit(issue)
return puts "Pass options you need to update" if options.blank?
issue = client_class.find(issue)
opts = suggest_options(resources: { issue: issue, editor: use_editor(keys) })
opts = suggest_options(resources: { issue: issue, editor: options.editor })
suggest_related_value_options(opts)

issue = client_class.update(issue, opts)
Expand All @@ -85,10 +84,10 @@ def delete(issue)
end

desc 'comment [ISSUE_KEY]', 'Write comment on the issue'
jira_options :comment
def comment(*keys)
issue = keys[0]
opts = suggest_options(required: [:comment], resources: { editor: use_editor(keys) })
jira_options :comment, :editor
def comment(issue)
puts options.editor
opts = suggest_options(required: [:comment], resources: { editor: options.editor })
issue = client_class.write_comment(issue, opts[:comment])
render_issue_detail(issue)
end
Expand Down Expand Up @@ -145,11 +144,5 @@ def default_status_categories
Client::StatusCategory.all.reject { |category| category.key =~ /done/i }.map(&:key)
end
end

private

def use_editor(keys)
keys.any? { |key| key == '-e' || key == '--editor' }
end
end
end
4 changes: 4 additions & 0 deletions lib/terjira/option_support/shared_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ module SharedOptions
'epiclink' => {
type: :string,
aliases: '-e'
},
'editor' => {
type: :boolean,
aliases: '-E'
}
}.freeze

Expand Down

0 comments on commit d30c951

Please sign in to comment.