1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

CLI: simplify Slop switch declarations

`on :foo=` is the synonym for `on :foo, :argument => true`.
This commit is contained in:
Kyrylo Silin 2013-01-30 15:10:40 +02:00
parent fc522f837a
commit 4bb7bd2ac9

View file

@ -99,10 +99,10 @@ Pry::CLI.add_options do
banner %{Usage: pry [OPTIONS] banner %{Usage: pry [OPTIONS]
Start a Pry session. Start a Pry session.
See: `https://github.com/pry` for more information. See: `https://github.com/pry` for more information.
Copyright (c) 2011 John Mair (banisterfiend) Copyright (c) 2013 John Mair (banisterfiend)
-- --
} }
on :e, :exec, "A line of code to execute in context before the session starts", :argument => true do |input| on :e, :exec=, "A line of code to execute in context before the session starts" do |input|
exec_string << input + "\n" exec_string << input + "\n"
end end
@ -123,12 +123,12 @@ Copyright (c) 2011 John Mair (banisterfiend)
Pry.config.should_load_local_rc = false Pry.config.should_load_local_rc = false
end end
on :s, "select-plugin", "Only load specified plugin (and no others).", :argument => true do |plugin_name| on :s, "select-plugin=", "Only load specified plugin (and no others)." do |plugin_name|
Pry.config.should_load_plugins = false Pry.config.should_load_plugins = false
Pry.plugins[plugin_name].activate! Pry.plugins[plugin_name].activate!
end end
on :d, "disable-plugin", "Disable a specific plugin.", :argument => true do |plugin_name| on :d, "disable-plugin=", "Disable a specific plugin." do |plugin_name|
Pry.plugins[plugin_name].disable! Pry.plugins[plugin_name].disable!
end end
@ -149,11 +149,11 @@ Copyright (c) 2011 John Mair (banisterfiend)
Pry.config.prompt = Pry::SIMPLE_PROMPT Pry.config.prompt = Pry::SIMPLE_PROMPT
end end
on :r, :require, "`require` a Ruby script at startup", :argument => true do |file| on :r, :require=, "`require` a Ruby script at startup" do |file|
Pry.config.requires << file Pry.config.requires << file
end end
on :I, "Add a path to the $LOAD_PATH", :argument => true, :as => Array, :delimiter => ":" do |load_path| on :I=, "Add a path to the $LOAD_PATH", :as => Array, :delimiter => ":" do |load_path|
load_path.map! do |path| load_path.map! do |path|
/\A\.\// =~ path ? path : File.expand_path(path) /\A\.\// =~ path ? path : File.expand_path(path)
end end
@ -166,9 +166,8 @@ Copyright (c) 2011 John Mair (banisterfiend)
exit exit
end end
on(:c, :context, on(:c, :context=,
"Start the session in the specified context. Equivalent to `context.pry` in a session.", "Start the session in the specified context. Equivalent to `context.pry` in a session.",
:argument => true,
:default => "Pry.toplevel_binding" :default => "Pry.toplevel_binding"
) )
end.process_options do |opts| end.process_options do |opts|