console1984
console1984 copied to clipboard
Add support for pry
Any statements entered while inside a pry console aren't added to the console1984_commands table.
Steps to reproduce
I created a dummy repo to test this. It's a vanilla rails new on version 7.0.4.2 with pry and console1984 added.
console1984-pry-test % CONSOLE_USER=james bin/rails c
# ... console1984 setup truncated ...
Loading development environment (Rails 7.0.4.2)
irb(main):001:0> puts "Before pry"
Before pry
=> nil
irb(main):002:0> pry
[1] pry(main)> puts "Inside pry"
Inside pry
=> nil
[2] pry(main)> exit
=> nil
irb(main):003:0> puts "After pry"
After pry
=> nil
irb(main):004:0> exit
Expected logged commands
puts "Before pry"
pry
puts "Inside pry"
exit
puts "After pry"
exit
Actual logged commands
console1984-pry-test % bin/rails runner "puts Console1984::Session.last.commands.map(&:statements)"
puts "Before pry"
pry
puts "After pry"
exit
Extra info
rails version 7.0.4.2 console1984 version 0.1.26 pry version 0.14.2
I've tried gem "pry", require: false and changing the order of gems in the Gemfile, but the result always appears to be the same.
Thanks @ohthatjames. Thanks for reporting. console1984 currently only supports IRB, which is what we use at 37signals. I would be happy to welcome a PR adding support for pry too.
This is far from complete, but this will get you going:
Pry.prepend(Module.new do
include Console1984::Freezeable
def process_command(line, ...)
Console1984.command_executor.execute(Array(line)) do
super
end
end
end)
That will capture the history, at the very least.