diff --git a/lib/pry/command_set.rb b/lib/pry/command_set.rb index adafd084..e3b066ff 100644 --- a/lib/pry/command_set.rb +++ b/lib/pry/command_set.rb @@ -263,6 +263,17 @@ class Pry commands.delete(cmd.match) end + def deprecated_command(name_of_deprecated_command, deprecation_message, matcher=name_of_deprecated_command) + create_command name_of_deprecated_command do + match matcher + description "" + + define_method(:process) do + output.puts "DEPRECATED: #{deprecation_message}" + end + end + end + # Sets or gets the description for a command (replacing the old # description). Returns current description if no description # parameter provided. diff --git a/lib/pry/commands/code_collector.rb b/lib/pry/commands/code_collector.rb index 4e5522a1..a17fca28 100644 --- a/lib/pry/commands/code_collector.rb +++ b/lib/pry/commands/code_collector.rb @@ -103,7 +103,7 @@ class Pry pry_array_content_as_string(_pry_.input_array, self.class.input_expression_ranges) { |v| v } end - # The line range passed to `--lines` + # The line range passed to `--lines`, converted to a 0-indexed range. def line_range opts.present?(:lines) ? one_index_range_or_number(opts[:lines]) : 0..-1 end @@ -144,7 +144,6 @@ class Pry if File.exists?(obj_name) # Set the file accessor. self.file = obj_name - File.read(obj_name) else could_not_locate(obj_name) diff --git a/lib/pry/commands/deprecated_commands.rb b/lib/pry/commands/deprecated_commands.rb new file mode 100644 index 00000000..a8c05c6d --- /dev/null +++ b/lib/pry/commands/deprecated_commands.rb @@ -0,0 +1,2 @@ +Pry::Commands.deprecated_command("edit-method", "Use `edit` instead.") +Pry::Commands.deprecated_command("show-command", "Use show-source [command_name] instead.") diff --git a/lib/pry/commands/edit_method.rb b/lib/pry/commands/edit_method.rb deleted file mode 100644 index 9b5c90e9..00000000 --- a/lib/pry/commands/edit_method.rb +++ /dev/null @@ -1,29 +0,0 @@ -class Pry - class Command::EditMethod < Pry::ClassCommand - match 'edit-method' - group 'Editing' - description 'Show the source for CMD.' - - banner <<-'BANNER' - Show the source for CMD. - BANNER - - def process(*args) - target = target() - - opts = Slop.parse!(args) do |opt| - opt.banner unindent <<-'BANNER' - NOTE: edit-method is DEPRECATED. Use `edit` instead. - BANNER - - opt.on :h, :help, "This message" do - output.puts opt.help - end - end - - stagger_output opts.banner - end - end - - Pry::Commands.add_command(Pry::Command::EditMethod) -end diff --git a/lib/pry/commands/show_command.rb b/lib/pry/commands/show_command.rb deleted file mode 100644 index fc0e844f..00000000 --- a/lib/pry/commands/show_command.rb +++ /dev/null @@ -1,29 +0,0 @@ -class Pry - class Command::ShowCommand < Pry::ClassCommand - match 'show-command' - group 'Introspection' - description 'Show the source for CMD.' - - banner <<-'BANNER' - Show the source for CMD. - BANNER - - def process(*args) - target = target() - - opts = Slop.parse!(args) do |opt| - opt.banner unindent <<-'BANNER' - NOTE: show-command is DEPRECATED. Use show-source [command_name] instead. - BANNER - - opt.on :h, :help, "This message" do - output.puts opt.help - end - end - - render_output opts.banner - end - end - - Pry::Commands.add_command(Pry::Command::ShowCommand) -end