mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
cli: parse_opts should not actually spin off a repl
This commit is contained in:
parent
65fdcba0d9
commit
f3339c8cef
3 changed files with 31 additions and 29 deletions
3
bin/pry
3
bin/pry
|
@ -13,4 +13,5 @@ rescue LoadError
|
|||
end
|
||||
|
||||
# Process command line options and run Pry
|
||||
Pry::CLI.parse_options
|
||||
opts = Pry::CLI.parse_options
|
||||
Pry::CLI.start(opts)
|
||||
|
|
|
@ -83,7 +83,31 @@ class Pry
|
|||
option_processors.each { |processor| processor.call(opts) }
|
||||
end
|
||||
|
||||
self
|
||||
opts
|
||||
end
|
||||
|
||||
def start(opts)
|
||||
exit if opts.help?
|
||||
|
||||
# invoked via cli
|
||||
Pry.cli = true
|
||||
|
||||
# create the actual context
|
||||
if opts[:context]
|
||||
Pry.initial_session_setup
|
||||
context = Pry.binding_for(eval(opts[:context]))
|
||||
else
|
||||
context = Pry.toplevel_binding
|
||||
end
|
||||
|
||||
if Pry::CLI.input_args.any? && Pry::CLI.input_args != ["pry"]
|
||||
full_name = File.expand_path(Pry::CLI.input_args.first)
|
||||
Pry.load_file_through_repl(full_name)
|
||||
exit
|
||||
end
|
||||
|
||||
# Start the session (running any code passed with -e, if there is any)
|
||||
Pry.start(context, :input => StringIO.new(Pry.config.exec_string))
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -93,9 +117,6 @@ class Pry
|
|||
end
|
||||
|
||||
|
||||
# String that is built to be executed on start (created by -e and -exec switches)
|
||||
exec_string = ""
|
||||
|
||||
# Bring in options defined by plugins
|
||||
Slop.new do
|
||||
on "no-plugins" do
|
||||
|
@ -116,7 +137,7 @@ Copyright (c) 2013 John Mair (banisterfiend)
|
|||
--
|
||||
}
|
||||
on :e, :exec=, "A line of code to execute in context before the session starts" do |input|
|
||||
exec_string + input + "\n"
|
||||
Pry.config.exec_string += input + "\n"
|
||||
end
|
||||
|
||||
on "no-pager", "Disable pager for long output" do
|
||||
|
@ -194,27 +215,4 @@ Copyright (c) 2013 John Mair (banisterfiend)
|
|||
"Start the session in the specified context. Equivalent to `context.pry` in a session.",
|
||||
:default => "Pry.toplevel_binding"
|
||||
)
|
||||
end.add_option_processor do |opts|
|
||||
|
||||
exit if opts.help?
|
||||
|
||||
# invoked via cli
|
||||
Pry.cli = true
|
||||
|
||||
# create the actual context
|
||||
if opts[:context]
|
||||
Pry.initial_session_setup
|
||||
context = Pry.binding_for(eval(opts[:context]))
|
||||
else
|
||||
context = Pry.toplevel_binding
|
||||
end
|
||||
|
||||
if Pry::CLI.input_args.any? && Pry::CLI.input_args != ["pry"]
|
||||
full_name = File.expand_path(Pry::CLI.input_args.first)
|
||||
Pry.load_file_through_repl(full_name)
|
||||
exit
|
||||
end
|
||||
|
||||
# Start the session (running any code passed with -e, if there is any)
|
||||
Pry.start(context, :input => StringIO.new(exec_string))
|
||||
end
|
||||
|
|
|
@ -110,6 +110,9 @@ class Pry::Config::Default
|
|||
completer: proc {
|
||||
require "pry/input_completer"
|
||||
Pry::InputCompleter
|
||||
},
|
||||
exec_string: proc {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue