R
R.. Kumar
Does Highline or Thor/Facets/ActiveSupport etc have a method for when
you want user to edit multiline text using the $EDITOR value?
Commander has but it does not work with vim. So i wrote a method, if
anyone has time please give it a look and give me feedback. Is it
correct to pass back a nil if user does not edit, or should I pass a
blank String.
Thanks. (File attached).
http://gist.github.com/456809
Also, following is the method "commander" has. It is supposed to work
with TextMate but does not with Vim. It does open TextEdit in the
background, but does not seem to put the text in it.
def ask_editor input = nil, editor = ENV['EDITOR'] || 'mate'
IO.popen(editor.to_s, 'w+') do |pipe|
pipe.puts input.to_s unless input.nil?
pipe.close_write
pipe.read
end
end
I'd like to know why the developer of commander used this instead of a
"system" command. In what way is this superior ? Why does it fail with
vim.
Attachments:
http://www.ruby-forum.com/attachment/4822/edit.rb
you want user to edit multiline text using the $EDITOR value?
Commander has but it does not work with vim. So i wrote a method, if
anyone has time please give it a look and give me feedback. Is it
correct to pass back a nil if user does not edit, or should I pass a
blank String.
Thanks. (File attached).
http://gist.github.com/456809
Also, following is the method "commander" has. It is supposed to work
with TextMate but does not with Vim. It does open TextEdit in the
background, but does not seem to put the text in it.
def ask_editor input = nil, editor = ENV['EDITOR'] || 'mate'
IO.popen(editor.to_s, 'w+') do |pipe|
pipe.puts input.to_s unless input.nil?
pipe.close_write
pipe.read
end
end
I'd like to know why the developer of commander used this instead of a
"system" command. In what way is this superior ? Why does it fail with
vim.
Attachments:
http://www.ruby-forum.com/attachment/4822/edit.rb