diff --git a/lib/pry/command_set.rb b/lib/pry/command_set.rb index a7dfb6a5..07aa9215 100644 --- a/lib/pry/command_set.rb +++ b/lib/pry/command_set.rb @@ -243,7 +243,7 @@ class Pry end end - command "install", "Install a disabled command." do |name| + command "install-command", "Install a disabled command." do |name| command = find_command(name) stub_info = command.options[:stub_info] diff --git a/lib/pry/default_commands/basic.rb b/lib/pry/default_commands/basic.rb index df195529..efafdd59 100644 --- a/lib/pry/default_commands/basic.rb +++ b/lib/pry/default_commands/basic.rb @@ -16,17 +16,34 @@ class Pry end end - command "version", "Show Pry version." do + command "pry-version", "Show Pry version." do output.puts "Pry version: #{Pry::VERSION} on Ruby #{RUBY_VERSION}." end - command "import", "Import a command set" do |command_set_name| + command "import-set", "Import a command set" do |command_set_name| next output.puts "Provide a command set name" if command_set.nil? set = target.eval(arg_string) Pry.active_instance.commands.import set end + command "reload-method", "Reload the source file that contains the specified method" do |meth_name| + if (meth = get_method_object(meth_name, target, {})).nil? + output.puts "Invalid method name: #{meth_name}." + next + end + + if is_a_c_method?(meth) + output.puts "Error: Can't reload a C method." + elsif is_a_dynamically_defined_method?(meth) + output.puts "Error: Can't reload an eval method." + else + file_name = meth.source_location.first + load file_name + output.puts "Reloaded #{file_name}." + end + end + command "reset", "Reset the REPL to a clean state." do output.puts "Pry reset." exec "pry"