visionmedia-commander 3.2.4 → 3.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +4 -0
- data/README.rdoc +7 -1
- data/commander.gemspec +1 -1
- data/lib/commander/user_interaction.rb +22 -0
- data/lib/commander/version.rb +1 -1
- metadata +1 -1
data/History.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -147,6 +147,12 @@ simplify common tasks using the following methods:
|
|
147
147
|
# Enable paging of output after this point
|
148
148
|
enable_paging
|
149
149
|
|
150
|
+
# Ask editor for input (EDITOR or TextMate by default)
|
151
|
+
ask_editor
|
152
|
+
|
153
|
+
# Ask editor, supplying initial text
|
154
|
+
ask_editor 'previous data to update'
|
155
|
+
|
150
156
|
== Commander Goodies
|
151
157
|
|
152
158
|
=== Option Defaults
|
@@ -284,7 +290,7 @@ http://visionmedia.lighthouseapp.com/projects/27643-commander
|
|
284
290
|
|
285
291
|
== Known Issues
|
286
292
|
|
287
|
-
*
|
293
|
+
* ask_editor has been tested with TextMate only
|
288
294
|
|
289
295
|
== License
|
290
296
|
|
data/commander.gemspec
CHANGED
@@ -35,6 +35,28 @@ module Commander
|
|
35
35
|
say '%15s %s' % [action, args.join(' ')]
|
36
36
|
end
|
37
37
|
|
38
|
+
##
|
39
|
+
# Prompt +editor+ for input. Optionally supply initial
|
40
|
+
# +input+ which is written to the editor.
|
41
|
+
#
|
42
|
+
# The +editor+ defaults to the EDITOR environment variable
|
43
|
+
# when present, or 'mate' for TextMate.
|
44
|
+
#
|
45
|
+
# === Examples
|
46
|
+
#
|
47
|
+
# ask_editor # => prompts EDITOR with no input
|
48
|
+
# ask_editor('foo') # => prompts EDITOR with default text of 'foo'
|
49
|
+
# ask_editor('foo', :mate) # => prompts TextMate with default text of 'foo'
|
50
|
+
#
|
51
|
+
|
52
|
+
def ask_editor input = nil, editor = ENV['EDITOR'] || 'mate'
|
53
|
+
IO.popen(editor.to_s, 'w+') do |pipe|
|
54
|
+
pipe.puts input.to_s unless input.nil?
|
55
|
+
pipe.close_write
|
56
|
+
pipe.read
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
38
60
|
##
|
39
61
|
# Enable paging of output after called.
|
40
62
|
|
data/lib/commander/version.rb
CHANGED