Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pry #89

Open
ohthatjames opened this issue Mar 1, 2023 · 2 comments
Open

Add support for pry #89

ohthatjames opened this issue Mar 1, 2023 · 2 comments

Comments

@ohthatjames
Copy link

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.

@jorgemanrubia jorgemanrubia changed the title Using pry disables command logging Add support for PRY Apr 4, 2023
@jorgemanrubia jorgemanrubia changed the title Add support for PRY Add support for pry Apr 4, 2023
@jorgemanrubia
Copy link
Member

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.

@dark-panda
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants