* PluginManager#load_cli_options: use the realpath
Since ruby 2.5, `require 'foo'` will use the realpath of the file
corresponding to foo.rb. However `require '/absolute/path/to/foo.rb'`
won't use the realpath.
So when $GEM_HOME contains a symlink (ie it is not the realpath), when a
pry plugin is loaded, by `activate!`:
require gem_name if !active?
the real_path of `gem_name` is used.
But then in load_cli_options:
cli_options_file = File.join(spec.full_gem_path, "lib/#{spec.name}/cli.rb")
require cli_options_file if File.exist?(cli_options_file)
since the path given is absolute, it will be used directly without realpath.
This means that cli.rb may potentially be required twice (once via its realpath if the plugin requires it, the other via its $GEM_HOME path when required by `load_cli_options`), which could raise some errors.
Fix this by using the realpath in load_cli_options too.
Revision r59984 in ruby 2.5 introduced the use of realpath for load paths,
and it was backported to version 2.4 in the minor revision 2.4.4. So
only use the realpath ourselves for ruby versions above or equal to
2.4.4.
I was getting trouble with both pry-editline and pry-syntax-hacks, while
running with a newly-compiled-Ruby with GNU Readline on a Mac (the
default Readline was working OK with these. There could be more
investigation about the error, but for now, at least pry boots with a
handy error instead of a total failure).
Whenever a plugin is activated a configuration object (using OpenStruct) will be
created in Pry.config for that plugin. For example, for the plugin "pry-doc" the
object Pry.config.pry_doc would be created.
See #436 for more information.
Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
Plugins can define their own command line options by having a lib/plugin_name/cli.rb file. If this file exists
it is loaded immediately before command line options are processed. The contents of the file should be along the lines of:
Pry::CLI.add_options do
on "my-option", "My first option!" do
puts "I just defined an option!"
end
end