Open st0012 opened 1 year ago
Please consider reusing the old command names. chws
is just... not good.
Hi. I find irb
command to be useful as an equivalent of pry cd.
For example when debugging session starts in irb console (like rails console - testing on staging case), not by putting binding.irb
in the tested file.
bin/rails console
# assume it's part of the application
class Greeter
def hello = "Hello, World!"
end
g = Greeter.new
irb g # <-----------------
Multi-irb commands are deprecated [...]
irb#1(#<Greeter:0x00007faa7b850188>):001> hello
=> "Hello, World!"
Ctrl-D
to get back.
UPDATE: OK, just realized that it's ~exactly~ what chws
is for :wink: Only more complex to remember the syntax:
pushws cwws
# => [main]
chws g
# => #<Greeter:0x00007f29077f5c38>
hello
# => "Hello, World!"
popws
# => []
Is there a way to go back without having first to push current workspace to the stack?
pry example:
[3] pry(main)> cd g
[4] pry(#<Greeter>):1> hello
# => "Hello, World!"
[5] pry(#<Greeter>):1> cd ..
[6] pry(main)>
My impression is that cd
, cd ..
is the human-friendly interface, while workspace commands are generally building blocks of it exposed to the user (missed one layer of abstraction).
@kml Thanks for the feedback 🙂 I'm adding a simpler cd
command in #971
I love how this got implemented.... Now whenever I try to assign to an instance variable with the name jobs
it now prints a message and doesn't actually create the var... brilliant.
This implementation is a bit overly aggressive. As @jwkoelewijn points out, it breaks any code we might type or copy-paste that uses a jobs
instance variable:
worker (local) > jobs = Job.all
Multi-irb commands are deprecated and will be removed in IRB 2.0.0. Please use workspace commands instead.
If you have any use case for multi-irb, please leave a comment at https://github.com/ruby/irb/issues/653
#0->irb on main (#<Thread:0x0000ffff8239a7b0 run>: running)
=> nil
worker (local) > jobs
Multi-irb commands are deprecated and will be removed in IRB 2.0.0. Please use workspace commands instead.
If you have any use case for multi-irb, please leave a comment at https://github.com/ruby/irb/issues/653
#0->irb on main (#<Thread:0x0000ffff8239a7b0 run>: running)
=> nil
Is there a way we can not break assignment to a variable named jobs
?
Usability problem of local variable and command is fixed in https://github.com/ruby/irb/pull/961 and released
# irb -v
irb 1.14.0 (2024-07-06)
# irb
irb(main):001> jobs = [1, 2, 3]
=> [1, 2, 3]
irb(main):002> jobs
=> [1, 2, 3]
irb(main):003>
Sweet, thanks! 🙌🏼
Something I miss without being able to just run irb
everywhere is being able to inspect something that only exists for the duration of a block - eg:
irb(main):002:0> File.open("/etc/hosts") { |f| irb f }
irb#1(#<File:0x000055be023ef240>):001:0> self.size
=> 174
and then being able to iteratively experiment with methods on the object yielded to the block. (pretending for the moment that File.open doesn't support a blockless variant)
Is there an equivalent version that works without multi-irb?
[EDIT: Oh, maybe I should just be using binding.irb
?
irb(main):001> File.open("/etc/hosts") { |f| binding.irb }
irb(main):001> f.size
=> 1063
]
Plan
irb
,jobs
,fg
, andkill
in the next minor releasev2.0.0
Reasons
chws
,pushws
...etc.Feedback wanted
If you use the multi-irb feature and don't want to see it deprecated from IRB, please leave a comment below to explain your use case of it. It will help us assess this plan.