pry 0.9.7.4 → 0.9.8pre2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -3
- data/README.markdown +3 -1
- data/Rakefile +48 -31
- data/bin/pry +2 -80
- data/lib/pry.rb +17 -20
- data/lib/pry/cli.rb +152 -0
- data/lib/pry/command_processor.rb +13 -0
- data/lib/pry/command_set.rb +102 -9
- data/lib/pry/config.rb +28 -6
- data/lib/pry/default_commands/context.rb +9 -8
- data/lib/pry/default_commands/documentation.rb +55 -13
- data/lib/pry/default_commands/easter_eggs.rb +1 -1
- data/lib/pry/default_commands/input.rb +25 -25
- data/lib/pry/default_commands/introspection.rb +19 -18
- data/lib/pry/default_commands/ls.rb +23 -38
- data/lib/pry/default_commands/shell.rb +47 -15
- data/lib/pry/helpers/command_helpers.rb +28 -6
- data/lib/pry/helpers/options_helpers.rb +7 -4
- data/lib/pry/helpers/text.rb +23 -3
- data/lib/pry/history.rb +55 -17
- data/lib/pry/history_array.rb +2 -0
- data/lib/pry/hooks.rb +108 -0
- data/lib/pry/indent.rb +9 -5
- data/lib/pry/method.rb +99 -50
- data/lib/pry/plugins.rb +10 -2
- data/lib/pry/pry_class.rb +48 -20
- data/lib/pry/pry_instance.rb +106 -91
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +73 -0
- data/man/pry.1 +195 -0
- data/man/pry.1.html +204 -0
- data/man/pry.1.ronn +141 -0
- data/pry.gemspec +21 -24
- data/test/helper.rb +12 -3
- data/test/test_cli.rb +78 -0
- data/test/test_command_set.rb +193 -1
- data/test/test_default_commands/test_context.rb +19 -4
- data/test/test_default_commands/test_input.rb +2 -2
- data/test/test_default_commands/test_introspection.rb +63 -6
- data/test/test_default_commands/test_ls.rb +8 -35
- data/test/test_default_commands/test_shell.rb +36 -1
- data/test/test_hooks.rb +175 -0
- data/test/test_indent.rb +2 -0
- data/test/test_method.rb +10 -0
- data/test/test_pry.rb +35 -34
- data/test/test_pry_history.rb +24 -24
- data/test/test_syntax_checking.rb +47 -0
- data/test/test_wrapped_module.rb +71 -0
- metadata +40 -34
@@ -101,6 +101,17 @@ class Pry
|
|
101
101
|
[cmd_data, (Regexp.last_match ? Regexp.last_match.captures : nil), (Regexp.last_match ? Regexp.last_match.end(0) : nil)]
|
102
102
|
end
|
103
103
|
|
104
|
+
# Display a warning if a command collides with a local/method in
|
105
|
+
# the current scope.
|
106
|
+
# @param [String] command_name_match The name of the colliding command.
|
107
|
+
# @param [Binding] target The current binding context.
|
108
|
+
def check_for_command_name_collision(command_name_match, target)
|
109
|
+
if collision_type = target.eval("defined?(#{command_name_match})")
|
110
|
+
pry_instance.output.puts "#{Pry::Helpers::Text.bold('WARNING:')} Command name collision with a #{collision_type}: '#{command_name_match}'\n\n"
|
111
|
+
end
|
112
|
+
rescue Pry::RescuableException
|
113
|
+
end
|
114
|
+
|
104
115
|
# Process Pry commands. Pry commands are not Ruby methods and are evaluated
|
105
116
|
# prior to Ruby expressions.
|
106
117
|
# Commands can be modified/configured by the user: see `Pry::Commands`
|
@@ -123,6 +134,8 @@ class Pry
|
|
123
134
|
|
124
135
|
arg_string = val[pos..-1]
|
125
136
|
|
137
|
+
check_for_command_name_collision(val[0..pos].rstrip, target) if Pry.config.collision_warning
|
138
|
+
|
126
139
|
# remove the one leading space if it exists
|
127
140
|
arg_string.slice!(0) if arg_string.start_with?(" ")
|
128
141
|
|
data/lib/pry/command_set.rb
CHANGED
@@ -142,6 +142,46 @@ class Pry
|
|
142
142
|
commands[name] = Command.new(name, description, options, block)
|
143
143
|
end
|
144
144
|
|
145
|
+
# Execute a block of code before a command is invoked. The block also
|
146
|
+
# gets access to parameters that will be passed to the command and
|
147
|
+
# is evaluated in the same context.
|
148
|
+
# @param [String, Regexp] name The name of the command.
|
149
|
+
# @yield The block to be run before the command.
|
150
|
+
# @example Display parameter before invoking command
|
151
|
+
# Pry.commands.before_command("whereami") do |n|
|
152
|
+
# output.puts "parameter passed was #{n}"
|
153
|
+
# end
|
154
|
+
def before_command(name, &block)
|
155
|
+
cmd = find_command_by_name_or_listing(name)
|
156
|
+
prev_block = cmd.block
|
157
|
+
|
158
|
+
wrapper_block = proc do |*args|
|
159
|
+
instance_exec(*args, &block)
|
160
|
+
instance_exec(*args, &prev_block)
|
161
|
+
end
|
162
|
+
cmd.block = wrapper_block
|
163
|
+
end
|
164
|
+
|
165
|
+
# Execute a block of code after a command is invoked. The block also
|
166
|
+
# gets access to parameters that will be passed to the command and
|
167
|
+
# is evaluated in the same context.
|
168
|
+
# @param [String, Regexp] name The name of the command.
|
169
|
+
# @yield The block to be run after the command.
|
170
|
+
# @example Display text 'command complete' after invoking command
|
171
|
+
# Pry.commands.after_command("whereami") do |n|
|
172
|
+
# output.puts "command complete!"
|
173
|
+
# end
|
174
|
+
def after_command(name, &block)
|
175
|
+
cmd = find_command_by_name_or_listing(name)
|
176
|
+
prev_block = cmd.block
|
177
|
+
|
178
|
+
wrapper_block = proc do |*args|
|
179
|
+
instance_exec(*args, &prev_block)
|
180
|
+
instance_exec(*args, &block)
|
181
|
+
end
|
182
|
+
cmd.block = wrapper_block
|
183
|
+
end
|
184
|
+
|
145
185
|
def each &block
|
146
186
|
@commands.each(&block)
|
147
187
|
end
|
@@ -149,7 +189,10 @@ class Pry
|
|
149
189
|
# Removes some commands from the set
|
150
190
|
# @param [Array<String>] names name of the commands to remove
|
151
191
|
def delete(*names)
|
152
|
-
names.each
|
192
|
+
names.each do |name|
|
193
|
+
cmd = find_command_by_name_or_listing(name)
|
194
|
+
commands.delete cmd.name
|
195
|
+
end
|
153
196
|
end
|
154
197
|
|
155
198
|
# Imports all the commands from one or more sets.
|
@@ -167,19 +210,63 @@ class Pry
|
|
167
210
|
# @param [Array<String>] names Commands to import
|
168
211
|
def import_from(set, *names)
|
169
212
|
helper_module.send :include, set.helper_module
|
170
|
-
names.each
|
213
|
+
names.each do |name|
|
214
|
+
cmd = set.find_command_by_name_or_listing(name)
|
215
|
+
commands[cmd.name] = cmd
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
# @param [String, Regexp] name_or_listing The name or listing name
|
220
|
+
# of the command to retrieve.
|
221
|
+
# @return [Command] The command object matched.
|
222
|
+
def find_command_by_name_or_listing(name_or_listing)
|
223
|
+
if commands[name_or_listing]
|
224
|
+
cmd = commands[name_or_listing]
|
225
|
+
else
|
226
|
+
_, cmd = commands.find { |name, command| command.options[:listing] == name_or_listing }
|
227
|
+
end
|
228
|
+
|
229
|
+
raise ArgumentError, "Cannot find a command with name: '#{name_or_listing}'!" if !cmd
|
230
|
+
cmd
|
171
231
|
end
|
232
|
+
protected :find_command_by_name_or_listing
|
172
233
|
|
173
234
|
# Aliases a command
|
174
235
|
# @param [String] new_name New name of the command.
|
175
236
|
# @param [String] old_name Old name of the command.
|
176
237
|
# @param [String, nil] desc New description of the command.
|
177
238
|
def alias_command(new_name, old_name, desc="")
|
178
|
-
|
239
|
+
orig_command = find_command_by_name_or_listing(old_name)
|
240
|
+
commands[new_name] = orig_command.dup
|
179
241
|
commands[new_name].name = new_name
|
180
242
|
commands[new_name].description = desc
|
181
243
|
end
|
182
244
|
|
245
|
+
# Rename a command. Accepts either actual name or listing name for
|
246
|
+
# the `old_name`.
|
247
|
+
# `new_name` must be the actual name of the new command.
|
248
|
+
# @param [String, Regexp] new_name The new name for the command.
|
249
|
+
# @param [String, Regexp] old_name The command's current name.
|
250
|
+
# @param [Hash] options The optional configuration parameters,
|
251
|
+
# accepts the same as the `command` method, but also allows the
|
252
|
+
# command description to be passed this way too.
|
253
|
+
# @example Renaming the `ls` command and changing its description.
|
254
|
+
# Pry.config.commands.rename "dir", "ls", :description => "DOS friendly ls"
|
255
|
+
def rename_command(new_name, old_name, options={})
|
256
|
+
cmd = find_command_by_name_or_listing(old_name)
|
257
|
+
|
258
|
+
options = {
|
259
|
+
:listing => new_name,
|
260
|
+
:description => cmd.description
|
261
|
+
}.merge!(options)
|
262
|
+
|
263
|
+
commands[new_name] = cmd.dup
|
264
|
+
commands[new_name].name = new_name
|
265
|
+
commands[new_name].description = options.delete(:description)
|
266
|
+
commands[new_name].options.merge!(options)
|
267
|
+
commands.delete(cmd.name)
|
268
|
+
end
|
269
|
+
|
183
270
|
# Runs a command.
|
184
271
|
# @param [Object] context Object which will be used as self during the
|
185
272
|
# command.
|
@@ -201,16 +288,22 @@ class Pry
|
|
201
288
|
end
|
202
289
|
end
|
203
290
|
|
204
|
-
# Sets the description for a command (replacing the old
|
205
|
-
# description.
|
206
|
-
#
|
291
|
+
# Sets or gets the description for a command (replacing the old
|
292
|
+
# description). Returns current description if no description
|
293
|
+
# parameter provided.
|
294
|
+
# @param [String, Regexp] name The command name.
|
207
295
|
# @param [String] description The command description.
|
208
|
-
# @example
|
296
|
+
# @example Setting
|
209
297
|
# MyCommands = Pry::CommandSet.new do
|
210
298
|
# desc "help", "help description"
|
211
299
|
# end
|
212
|
-
|
213
|
-
|
300
|
+
# @example Getting
|
301
|
+
# Pry.config.commands.desc "amend-line"
|
302
|
+
def desc(name, description=nil)
|
303
|
+
cmd = find_command_by_name_or_listing(name)
|
304
|
+
return cmd.description if !description
|
305
|
+
|
306
|
+
cmd.description = description
|
214
307
|
end
|
215
308
|
|
216
309
|
# Defines helpers methods for this command sets.
|
data/lib/pry/config.rb
CHANGED
@@ -98,14 +98,20 @@ class Pry
|
|
98
98
|
# @return [Boolean]
|
99
99
|
attr_accessor :disable_auto_reload
|
100
100
|
|
101
|
+
# Determines whether Pry should trap SIGINT and cause it to raise an
|
102
|
+
# Interrupt exception. This is only useful on jruby, MRI does this
|
103
|
+
# for us.
|
104
|
+
# @return [Boolean]
|
105
|
+
attr_accessor :should_trap_interrupts
|
106
|
+
|
101
107
|
# Config option for history.
|
102
|
-
# sub-options include
|
103
|
-
#
|
108
|
+
# sub-options include history.file, history.load, and history.save
|
109
|
+
# history.file is the file to save/load history to, e.g
|
104
110
|
# Pry.config.history.file = "~/.pry_history".
|
105
|
-
#
|
106
|
-
# loaded from
|
107
|
-
#
|
108
|
-
# saved to
|
111
|
+
# history.should_load is a boolean that determines whether history will be
|
112
|
+
# loaded from history.file at session start.
|
113
|
+
# history.should_save is a boolean that determines whether history will be
|
114
|
+
# saved to history.file at session end.
|
109
115
|
# @return [OpenStruct]
|
110
116
|
attr_accessor :history
|
111
117
|
|
@@ -138,6 +144,22 @@ class Pry
|
|
138
144
|
# @return [Boolean] Whether or not indentation should be corrected
|
139
145
|
# after hitting enter. This feature is not supported by all terminals.
|
140
146
|
attr_accessor :correct_indent
|
147
|
+
|
148
|
+
# @return [Boolean] Whether or not a warning will be displayed when
|
149
|
+
# a command name collides with a method/local in the current context.
|
150
|
+
attr_accessor :collision_warning
|
151
|
+
|
152
|
+
|
153
|
+
# Config option for gist.
|
154
|
+
# sub-options include `gist.inspecter`,
|
155
|
+
# `gist.inspecter` is a callable that defines how the expression output
|
156
|
+
# will be displayed when using the `gist -i` command.
|
157
|
+
# @example Pretty inspect output
|
158
|
+
# Pry.config.gist.inspecter = proc { |v| v.pretty_inspect }
|
159
|
+
# @example Regular inspect
|
160
|
+
# Pry.config.gist.inspecter = proc &:inspect
|
161
|
+
# @return [OpenStruct]
|
162
|
+
attr_accessor :gist
|
141
163
|
end
|
142
164
|
end
|
143
165
|
|
@@ -127,10 +127,14 @@ class Pry
|
|
127
127
|
target.pry
|
128
128
|
end
|
129
129
|
|
130
|
+
command "pry-backtrace", "Show the backtrace for the Pry session" do
|
131
|
+
output.puts "\n#{text.bold('Backtrace:')}\n--\n"
|
132
|
+
output.puts _pry_.backtrace
|
133
|
+
end
|
134
|
+
|
130
135
|
command "whereami", "Show the code context for the session. (whereami <n> shows <n> extra lines of code around the invocation line. Default: 5)" do |num|
|
131
136
|
file = target.eval('__FILE__')
|
132
137
|
line_num = target.eval('__LINE__')
|
133
|
-
klass = target.eval('self.class')
|
134
138
|
|
135
139
|
if num
|
136
140
|
i_num = num.to_i
|
@@ -138,18 +142,15 @@ class Pry
|
|
138
142
|
i_num = 5
|
139
143
|
end
|
140
144
|
|
141
|
-
if (meth = Pry::Method.from_binding(target))
|
142
|
-
meth_name = meth.name
|
143
|
-
else
|
144
|
-
meth_name = "N/A"
|
145
|
-
end
|
146
|
-
|
147
145
|
if file != Pry.eval_path && (file =~ /(\(.*\))|<.*>/ || file == "" || file == "-e")
|
148
146
|
raise CommandError, "Cannot find local context. Did you use `binding.pry`?"
|
149
147
|
end
|
150
148
|
|
151
149
|
set_file_and_dir_locals(file)
|
152
|
-
|
150
|
+
|
151
|
+
method = Pry::Method.from_binding(target)
|
152
|
+
method_description = method ? " in #{method.name_with_owner}" : ""
|
153
|
+
output.puts "\n#{text.bold('From:')} #{file} @ line #{line_num}#{method_description}:\n\n"
|
153
154
|
|
154
155
|
if file == Pry.eval_path
|
155
156
|
f = Pry.line_buffer[1..-1]
|
@@ -26,7 +26,7 @@ class Pry
|
|
26
26
|
output.puts "#{text.bold("Visibility:")} #{meth.visibility}"
|
27
27
|
output.puts "#{text.bold("Signature:")} #{meth.signature}"
|
28
28
|
output.puts
|
29
|
-
render_output(opts.flood
|
29
|
+
render_output(opts.present?(:flood), false, doc)
|
30
30
|
end
|
31
31
|
|
32
32
|
alias_command "?", "show-doc"
|
@@ -55,29 +55,43 @@ class Pry
|
|
55
55
|
EOS
|
56
56
|
end
|
57
57
|
|
58
|
-
command "gist
|
58
|
+
command "gist", "Gist a method or expression history to github. Type `gist --help` for more info.", :requires_gem => "gist", :shellwords => false do |*args|
|
59
59
|
require 'gist'
|
60
60
|
|
61
61
|
target = target()
|
62
62
|
|
63
|
-
opts
|
63
|
+
opts = parse_options!(args) do |opt|
|
64
64
|
opt.banner unindent <<-USAGE
|
65
|
-
Usage: gist
|
66
|
-
Gist
|
65
|
+
Usage: gist [OPTIONS] [METH]
|
66
|
+
Gist method (doc or source) or input expression to github.
|
67
67
|
Ensure the `gist` gem is properly working before use. http://github.com/defunkt/gist for instructions.
|
68
68
|
e.g: gist -m my_method
|
69
69
|
e.g: gist -d my_method
|
70
|
+
e.g: gist -i 1..10
|
70
71
|
USAGE
|
71
72
|
|
72
|
-
opt.on :d, :doc, "Gist a method's documentation."
|
73
|
-
opt.on :
|
73
|
+
opt.on :d, :doc, "Gist a method's documentation.", true
|
74
|
+
opt.on :m, :method, "Gist a method's source.", true
|
75
|
+
opt.on :p, :public, "Create a public gist (default: false)", :default => false
|
76
|
+
opt.on :i, :in, "Gist entries from Pry's input expression history. Takes an index or range.", :optional => true, :as => Range, :default => -5..-1
|
74
77
|
end
|
75
78
|
|
76
79
|
type_map = { :ruby => "rb", :c => "c", :plain => "plain" }
|
77
|
-
if
|
78
|
-
|
79
|
-
|
80
|
-
|
80
|
+
if opts.present?(:in)
|
81
|
+
code_type = :ruby
|
82
|
+
content = ""
|
83
|
+
normalized_range = absolute_index_range(opts[:i], _pry_.input_array.length)
|
84
|
+
input_items = _pry_.input_array[normalized_range] || []
|
85
|
+
|
86
|
+
input_items.each_with_index.map do |code, index|
|
87
|
+
corrected_index = index + normalized_range.first
|
88
|
+
if code && code != ""
|
89
|
+
content << code
|
90
|
+
content << "#{comment_expression_result_for_gist(Pry.config.gist.inspecter.call(_pry_.output_array[corrected_index]))}" if code !~ /;\Z/
|
91
|
+
end
|
92
|
+
end
|
93
|
+
elsif opts.present?(:doc)
|
94
|
+
meth = get_method_or_raise(opts[:d], target, {})
|
81
95
|
content = meth.doc
|
82
96
|
code_type = meth.source_type
|
83
97
|
|
@@ -85,14 +99,42 @@ class Pry
|
|
85
99
|
content = process_comment_markup(content, code_type)
|
86
100
|
end
|
87
101
|
code_type = :plain
|
102
|
+
elsif opts.present?(:method)
|
103
|
+
meth = get_method_or_raise(opts[:m], target, {})
|
104
|
+
content = meth.source
|
105
|
+
code_type = meth.source_type
|
88
106
|
end
|
89
107
|
|
108
|
+
# prevent Gist from exiting the session on error
|
109
|
+
begin
|
90
110
|
link = Gist.write([:extension => ".#{type_map[code_type]}",
|
91
111
|
:input => content],
|
92
|
-
opts
|
112
|
+
!opts[:p])
|
113
|
+
rescue SystemExit
|
114
|
+
end
|
93
115
|
|
94
|
-
|
116
|
+
if link
|
117
|
+
Gist.copy(link)
|
118
|
+
output.puts "Gist created at #{link} and added to clipboard."
|
119
|
+
end
|
95
120
|
end
|
121
|
+
|
122
|
+
|
123
|
+
helpers do
|
124
|
+
def comment_expression_result_for_gist(result)
|
125
|
+
content = ""
|
126
|
+
result.lines.each_with_index do |line, index|
|
127
|
+
if index == 0
|
128
|
+
content << "# => #{line}"
|
129
|
+
else
|
130
|
+
content << "# #{line}"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
content
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
|
96
138
|
end
|
97
139
|
end
|
98
140
|
end
|
@@ -32,7 +32,7 @@ class Pry
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
next if opts.
|
35
|
+
next if opts.present?(:help)
|
36
36
|
|
37
37
|
if eval_string.empty?
|
38
38
|
raise CommandError, "No input to amend."
|
@@ -57,7 +57,7 @@ class Pry
|
|
57
57
|
run "show-input"
|
58
58
|
end
|
59
59
|
|
60
|
-
alias_command(/%.?(-?\d+)?(?:\.\.(-?\d+))?/,
|
60
|
+
alias_command(/%.?(-?\d+)?(?:\.\.(-?\d+))?/, "amend-line")
|
61
61
|
|
62
62
|
command "play", "Play back a string variable or a method or a file as input. Type `play --help` for more information." do |*args|
|
63
63
|
opts = Slop.parse!(args) do |opt|
|
@@ -78,16 +78,16 @@ class Pry
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
if opts.
|
81
|
+
if opts.present?(:method)
|
82
82
|
meth_name = opts[:m]
|
83
83
|
meth = get_method_or_raise(meth_name, target, {}, :omit_help)
|
84
84
|
next unless meth.source
|
85
85
|
|
86
|
-
range = opts.
|
87
|
-
range = (0..-2) if opts.
|
86
|
+
range = opts.present?(:lines) ? one_index_range_or_number(opts[:l]) : (0..-1)
|
87
|
+
range = (0..-2) if opts.present?(:open)
|
88
88
|
|
89
89
|
eval_string << Array(meth.source.each_line.to_a[range]).join
|
90
|
-
elsif opts.
|
90
|
+
elsif opts.present?(:file)
|
91
91
|
file_name = File.expand_path(opts[:f])
|
92
92
|
|
93
93
|
if !File.exists?(file_name)
|
@@ -95,8 +95,8 @@ class Pry
|
|
95
95
|
end
|
96
96
|
|
97
97
|
text_array = File.readlines(file_name)
|
98
|
-
range = opts.
|
99
|
-
range = (0..-2) if opts.
|
98
|
+
range = opts.present?(:lines) ? one_index_range_or_number(opts[:l]) : (0..-1)
|
99
|
+
range = (0..-2) if opts.present?(:open)
|
100
100
|
|
101
101
|
_pry_.input_stack << _pry_.input
|
102
102
|
_pry_.input = StringIO.new(Array(text_array[range]).join)
|
@@ -107,13 +107,13 @@ class Pry
|
|
107
107
|
|
108
108
|
code = target.eval(args.first)
|
109
109
|
|
110
|
-
range = opts.
|
111
|
-
range = (0..-2) if opts.
|
110
|
+
range = opts.present?(:lines) ? one_index_range_or_number(opts[:l]) : (0..-1)
|
111
|
+
range = (0..-2) if opts.present?(:open)
|
112
112
|
|
113
113
|
eval_string << Array(code.each_line.to_a[range]).join
|
114
114
|
end
|
115
115
|
|
116
|
-
run "show-input" if !_pry_.
|
116
|
+
run "show-input" if !_pry_.complete_expression?(eval_string)
|
117
117
|
end
|
118
118
|
|
119
119
|
command "hist", "Show and replay Readline history. Type `hist --help` for more info. Aliases: history" do |*args|
|
@@ -153,15 +153,15 @@ class Pry
|
|
153
153
|
output.puts opt.help
|
154
154
|
end
|
155
155
|
end
|
156
|
-
next if opts.help
|
156
|
+
next if opts.present?(:help)
|
157
157
|
|
158
|
-
if opts.grep
|
158
|
+
if opts.present?(:grep)
|
159
159
|
pattern = Regexp.new(arg_string.strip.split(/ /, 2).last.strip)
|
160
160
|
history.pop
|
161
161
|
|
162
162
|
history.map!.with_index do |element, index|
|
163
163
|
if element =~ pattern
|
164
|
-
if opts.
|
164
|
+
if opts.present?(:"no-numbers")
|
165
165
|
element
|
166
166
|
else
|
167
167
|
"#{text.blue index}: #{element}"
|
@@ -173,11 +173,11 @@ class Pry
|
|
173
173
|
next
|
174
174
|
end
|
175
175
|
|
176
|
-
if opts.head
|
176
|
+
if opts.present?(:head)
|
177
177
|
limit = opts['head'] || 10
|
178
178
|
list = history.first limit
|
179
179
|
lines = list.join("\n")
|
180
|
-
if opts.
|
180
|
+
if opts.present?(:"no-numbers")
|
181
181
|
stagger_output lines
|
182
182
|
else
|
183
183
|
stagger_output text.with_line_numbers(lines, 0)
|
@@ -185,14 +185,14 @@ class Pry
|
|
185
185
|
next
|
186
186
|
end
|
187
187
|
|
188
|
-
if opts.tail
|
188
|
+
if opts.present?(:tail)
|
189
189
|
limit = opts['tail'] || 10
|
190
190
|
offset = history.size - limit
|
191
191
|
offset = offset < 0 ? 0 : offset
|
192
192
|
|
193
193
|
list = history.last limit
|
194
194
|
lines = list.join("\n")
|
195
|
-
if opts.
|
195
|
+
if opts.present?(:'no-numbers')
|
196
196
|
stagger_output lines
|
197
197
|
else
|
198
198
|
stagger_output text.with_line_numbers(lines, offset)
|
@@ -200,11 +200,11 @@ class Pry
|
|
200
200
|
next
|
201
201
|
end
|
202
202
|
|
203
|
-
if opts.show
|
203
|
+
if opts.present?(:show)
|
204
204
|
range = opts['show']
|
205
205
|
start_line = range.is_a?(Range) ? range.first : range
|
206
206
|
lines = Array(history[range]).join("\n")
|
207
|
-
if opts.
|
207
|
+
if opts.present?(:'no-numbers')
|
208
208
|
stagger_output lines
|
209
209
|
else
|
210
210
|
stagger_output text.with_line_numbers(lines, start_line)
|
@@ -212,10 +212,10 @@ class Pry
|
|
212
212
|
next
|
213
213
|
end
|
214
214
|
|
215
|
-
if opts.exclude
|
215
|
+
if opts.present?(:exclude)
|
216
216
|
history.map!.with_index do |element, index|
|
217
217
|
unless command_processor.valid_command? element
|
218
|
-
if opts.
|
218
|
+
if opts.present?(:'no-numbers')
|
219
219
|
element
|
220
220
|
else
|
221
221
|
"#{text.blue index}: #{element}"
|
@@ -226,7 +226,7 @@ class Pry
|
|
226
226
|
next
|
227
227
|
end
|
228
228
|
|
229
|
-
if opts.replay
|
229
|
+
if opts.present?(:replay)
|
230
230
|
range = opts['replay']
|
231
231
|
actions = Array(history[range]).join("\n") + "\n"
|
232
232
|
_pry_.input_stack << _pry_.input
|
@@ -234,7 +234,7 @@ class Pry
|
|
234
234
|
next
|
235
235
|
end
|
236
236
|
|
237
|
-
if opts.clear
|
237
|
+
if opts.present?(:clear)
|
238
238
|
Pry.history.clear
|
239
239
|
output.puts 'History cleared.'
|
240
240
|
next
|
@@ -274,7 +274,7 @@ class Pry
|
|
274
274
|
end
|
275
275
|
|
276
276
|
lines = history.join("\n")
|
277
|
-
if opts.
|
277
|
+
if opts.present?(:'no-numbers')
|
278
278
|
stagger_output lines
|
279
279
|
else
|
280
280
|
stagger_output text.with_line_numbers(lines, 0)
|