eval('[__FILE__, __LINE__]') will not work in future Ruby.
Let's stop using it when Binding#source_location is available because it
prints noisy warnings.
Since Binding#source_location is added in Ruby 2.6
https://github.com/ruby/ruby/commit/571e48b7442, this commit is leaving
old code with branching by binding.respond_to?(:source_location).
Fixes#1871
This is in reference to issue #904. In said issue it was mentioned that
this should be a `-L` flag because it was ostensibly an extension of the
`-l` flag. Felt `-e` was more intention revealing.
Wrap command descriptions to 80 characters. Convert some string options
to symbols (where possible). Align options in code. Remove dots in the
end of switch descriptions.
Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
And implement play and save-file using the new delegator. 'gist' still needs
to be re-implemented using CodeCollector.
************
TODO:
**************
Couldn't write a test for `play --lines 4..5` with implied target.eval("__FILE__") parameter,
need to come up with a decent test.
John "banister" Mair describes the following key features of commands
as classes:
1. It enables people to extend them by either subclassing or
monkeypatching.
2. It enables them to provide their own API, so that for example, the
Pry::Command::Edit class could have class methods for people to
configure it.
Please, note that I didn't touch easter eggs commands. I also prettified
some strings (your source code reading experience should vastly improve!).
Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
`play 69` is a shortcut for `play --file #{_file_} --lines 69`. It plays
lines from the current file. Example (I omitted some useless
information):
pry(main)> show-source hello
def hello
binding.pry
true
puts "hi"
69
end
pry(main)> hello
1: def hello
=> 2: binding.pry
3: true
4: puts "hi"
5: 69
6: end
pry(main)> play 5
=> 69
pry(main)> play 3..4
hi
=> nil
pry(main)>
Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>