Improve `-I` option support
Namely, add support for multiple arguments for the `-I` option. For example: % pry -Ilib:../code/src Where `:` is the delimiter for paths. In the example above `./lib` and `../code/src` directories will be added to $LOAD_PATH array. Also, there was a bug in Slop with respect to parsing of "fuzzy options with arguments"[1]. It is fixed now, so the next version of Slop will indirectly resolve our issue #674 (-r/--require doesn't behave like irb's)[2]. And finally, wrap some very long lines in the "cli.rb" (this is just a cosmetic change). [1]: https://github.com/injekt/slop/issues/74 [2]: https://github.com/pry/pry/issues/674 Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
This commit is contained in:
parent
b4e80be3f3
commit
2e33c98d97
|
@ -57,12 +57,18 @@ class Pry
|
|||
end
|
||||
|
||||
def parse_options(args=ARGV.dup)
|
||||
raise NoOptionsError, "No command line options defined! Use Pry::CLI.add_options to add command line options." if !options
|
||||
unless options
|
||||
raise NoOptionsError, "No command line options defined! Use Pry::CLI.add_options to add command line options."
|
||||
end
|
||||
|
||||
self.input_args = args
|
||||
|
||||
opts = Slop.parse!(args, :help => true, :multiple_switches => false, &options)
|
||||
option_processors.each { |processor| processor.call(opts) } if option_processors # option processors are optional
|
||||
|
||||
# Option processors are optional.
|
||||
if option_processors
|
||||
option_processors.each { |processor| processor.call(opts) }
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
@ -139,8 +145,12 @@ Copyright (c) 2011 John Mair (banisterfiend)
|
|||
Pry.config.requires << file
|
||||
end
|
||||
|
||||
on :I, "Add a path to the $LOAD_PATH", :argument => true do |path|
|
||||
$LOAD_PATH << path
|
||||
on :I, "Add a path to the $LOAD_PATH", :argument => true, :as => Array, :delimiter => ":" do |load_path|
|
||||
load_path.map! do |path|
|
||||
/\A\.\// =~ path ? path : File.expand_path(path)
|
||||
end
|
||||
|
||||
$LOAD_PATH.unshift(*load_path)
|
||||
end
|
||||
|
||||
on :v, :version, "Display the Pry version" do
|
||||
|
|
Loading…
Reference in New Issue