Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default editor to write comments and descriptions if specified #43

Merged

Conversation

kimpers
Copy link
Contributor

@kimpers kimpers commented Aug 26, 2017

Descriptions and comments can be quite long and cumbersome to input in the default input prompt so therefore it's better to use the system default $EDITOR for composing the content.

This feature was requested in #40.
Feel free to comment on code style, it has been a while since I developed with Ruby

@kimpers kimpers force-pushed the edit-comment-in-default-editor branch 2 times, most recently from c628238 to 2cd1d8c Compare August 26, 2017 20:40
@kimpers kimpers force-pushed the edit-comment-in-default-editor branch from 2cd1d8c to 110eab4 Compare August 26, 2017 20:49
@keepcosmos
Copy link
Owner

Thanks for PR! First of all, Opening editor(it's what we need) is good for writing and editing long text.

But I think, the default should be inline or prompt. Opening editor should be optional (pass option arg or global configuration).

@kimpers kimpers force-pushed the edit-comment-in-default-editor branch from 82a39c3 to 61c7dc1 Compare August 27, 2017 11:59
@kimpers
Copy link
Contributor Author

kimpers commented Aug 27, 2017

That is a good idea. I have updated the pr to accept -e or --editor to open comment or description in the default editor

@kimpers kimpers changed the title Use default editor to write comments and descriptions if possible Use default editor to write comments and descriptions if specified Aug 27, 2017
@keepcosmos
Copy link
Owner

Thanks :) ,

There are 2 problem I found.
First, option -e is used for add Epic link. And Add to jira_options. That is above method definition.
Second, It needs fallback handling if $EDITOR env is not set.

Please fix 2 issues before I merge your nice code. :)

@kimpers kimpers force-pushed the edit-comment-in-default-editor branch 2 times, most recently from d30c951 to ca4d249 Compare August 28, 2017 20:34
@kimpers
Copy link
Contributor Author

kimpers commented Aug 28, 2017

Thank you for the feedback. I didn't understand what jira_options did initially.

I have cleaned up the code a bit, fixed so that it raises an error if you try to edit with an editor without having $EDITOR set to something or if the editor returns a non-zero status code.

I also changed the alternative argument for using an editor to -E

@kimpers kimpers force-pushed the edit-comment-in-default-editor branch from ca4d249 to 43127de Compare August 28, 2017 20:40
@kimpers kimpers force-pushed the edit-comment-in-default-editor branch from 43127de to 08bccbb Compare August 28, 2017 20:48
@keepcosmos
Copy link
Owner

keepcosmos commented Aug 30, 2017

Good, but you should fix one more thing. editor variable is not a resource of jira. I mean that editor boolean variable makes error when parsing jira resource.

So, you should handle editor option another way.

For example,

suggest_options(required: [:project, :summary, :issuetype],
                             editor: options.editor)

And please check, your code does not work :)

@kimpers
Copy link
Contributor Author

kimpers commented Aug 30, 2017

I apologize for breaking the code. I was manually testing the comment command and forgot to check new & edit. I will fix this as soon as possible

Regarding not passing it in resources. The reason for passing it as a resource was because it was a nice way to have it accessable in option_selector.rb.

How would you propose passing the value forward through option_supportable

send(selector_method) if selector_method
without having to modify the selector_method to take arguments?

I am apologize if this a stupid question, it's been a very long time since I did Ruby development 🙃

@keepcosmos
Copy link
Owner

How about pass editor option, like

suggest_options(required: [:project, :summary, :issuetype],  editor: options.editor)
def suggest_options(opts = {})
  with_editor = opts[:editor]
  ...
end
module Terjira
  module OptionSelector
    def self.with_editor=(with_editor)
      @with_editor = with_editor
    end

    def self.with_editor?
      @with_editor || false
    end

    ...
  end
end

I'm not sure my code works. It's just concept.

Please feel free to suggest any idea 😄

@kimpers kimpers force-pushed the edit-comment-in-default-editor branch from 76bf794 to 50cf1f4 Compare September 1, 2017 22:31
origin = options.dup
origin.delete(:editor)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing the issues earlier. Other logic that parses the options in the client couldn't handle the that the editor option was in the hash.

@kimpers
Copy link
Contributor Author

kimpers commented Sep 1, 2017

I have addressed your comments and the issues should be fixed now.

I think travis are having issues right now which is why one of the jobs is failing 😞

@kimpers kimpers force-pushed the edit-comment-in-default-editor branch from 50cf1f4 to 2d0a04e Compare September 2, 2017 19:53
@kimpers
Copy link
Contributor Author

kimpers commented Sep 2, 2017

Retriggering travis does not seem to help

@keepcosmos keepcosmos merged commit a8c27b0 into keepcosmos:master Sep 4, 2017
@keepcosmos
Copy link
Owner

keepcosmos commented Sep 4, 2017

I just merged your code, fixed travis issue and release 0.3.7. Thanks! ❤️
Please download the version and check! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants