Convert all commands to classes

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>
This commit is contained in:
Kyrylo Silin 2012-12-25 23:35:17 +02:00
parent c2050dbb49
commit ebccd57013
44 changed files with 242 additions and 117 deletions

View File

@ -1,8 +1,9 @@
class Pry
Pry::Commands.create_command(/amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/) do
class Command::AmendLine < Pry::ClassCommand
match /amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/
group 'Editing'
description "Amend a line of input in multi-line mode."
command_options :interpolate => false, :listing => "amend-line"
description 'Amend a line of input in multi-line mode.'
command_options :interpolate => false, :listing => 'amend-line'
banner <<-'BANNER'
Amend a line of input in multi-line mode. `amend-line N`, where the N in `amend-line N` represents line to replace.
@ -40,5 +41,7 @@ class Pry
run "show-input"
end
end
Pry::Commands.add_command(Pry::Command::AmendLine)
end

View File

@ -1,13 +1,16 @@
class Pry
Pry::Commands.create_command "!" do
class Command::Bang < Pry::ClassCommand
match '!'
group 'Editing'
description "Clear the input buffer. Useful if the parsing process goes " \
"wrong and you get stuck in the read loop."
description 'Clear the input buffer. Useful if the parsing process goes ' \
'wrong and you get stuck in the read loop.'
command_options :use_prefix => false
def process
output.puts "Input buffer cleared!"
eval_string.replace("")
output.puts 'Input buffer cleared!'
eval_string.replace('')
end
end
Pry::Commands.add_command(Pry::Command::Bang)
end

View File

@ -1,11 +1,14 @@
class Pry
Pry::Commands.create_command "!pry" do
class Command::BangPry < Pry::ClassCommand
match '!pry'
group 'Navigating Pry'
description "Start a Pry session on current self; this even works mid " \
"multi-line expression."
description 'Start a Pry session on current self; this even works mid ' \
'multi-line expression.'
def process
target.pry
end
end
Pry::Commands.add_command(Pry::Command::BangPry)
end

View File

@ -1,5 +1,6 @@
class Pry
Pry::Commands.create_command "cat" do
class Command::Cat < Pry::ClassCommand
match 'cat'
group 'Input and Output'
description "Show code from a file, Pry's input buffer, or the last " \
"exception."
@ -175,4 +176,6 @@ class Pry
end
end
end
Pry::Commands.add_command(Pry::Command::Cat)
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "cd" do
group "Context"
description "Move into a new context (object or scope)."
class Command::Cd < Pry::ClassCommand
match 'cd'
group 'Context'
description 'Move into a new context (object or scope).'
banner <<-BANNER
Usage: cd [OPTIONS] [--help]
@ -25,4 +26,6 @@ class Pry
_pry_.binding_stack = stack if stack
end
end
Pry::Commands.add_command(Pry::Command::Cd)
end

View File

@ -1,5 +1,6 @@
class Pry
Pry::Commands.create_command "disable-pry" do
class Command::DisablePry < Pry::ClassCommand
match 'disable-pry'
group 'Navigating Pry'
description 'Stops all future calls to pry and exits the current session.'
@ -21,4 +22,6 @@ class Pry
_pry_.run_command "exit"
end
end
Pry::Commands.add_command(Pry::Command::DisablePry)
end

View File

@ -6,9 +6,10 @@ class Pry
# the entire source code because an exception may happen anywhere in the
# code and there is no way to predict that. So we simply superimpose
# everything (admittedly, doing extra job).
Pry::Commands.create_command "edit" do
class Command::Edit < Pry::ClassCommand
match 'edit'
group 'Editing'
description "Invoke the default editor on a file."
description 'Invoke the default editor on a file.'
banner <<-BANNER
Usage: edit [--no-reload|--reload] [--line LINE] [--temp|--ex|FILE[:LINE]|--in N]
@ -175,4 +176,6 @@ class Pry
end
end
end
Pry::Commands.add_command(Pry::Command::Edit)
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "edit-method" do
class Command::EditMethod < Pry::ClassCommand
match 'edit-method'
group 'Editing'
description "Edit the source code for a method."
description 'Edit the source code for a method.'
banner <<-BANNER
Usage: edit-method [OPTIONS] [METH]
@ -177,4 +178,6 @@ class Pry
source
end
end
Pry::Commands.add_command(Pry::Command::EditMethod)
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "exit" do
class Command::Exit < Pry::ClassCommand
match 'exit'
group 'Navigating Pry'
description "Pop the previous binding (does NOT exit program). Aliases: quit"
description 'Pop the previous binding (does NOT exit program). Aliases: quit'
banner <<-BANNER
Usage: exit [OPTIONS] [--help]
@ -38,5 +39,6 @@ class Pry
end
end
Pry::Commands.alias_command "quit", "exit"
Pry::Commands.add_command(Pry::Command::Exit)
Pry::Commands.alias_command 'quit', 'exit'
end

View File

@ -1,8 +1,9 @@
class Pry
Pry::Commands.create_command "exit-all" do
class Command::ExitAll < Pry::ClassCommand
match 'exit-all'
group 'Navigating Pry'
description "End the current Pry session (popping all bindings) and " \
"returning to caller. Accepts optional return value. Aliases: !!@"
description 'End the current Pry session (popping all bindings) and ' \
'returning to caller. Accepts optional return value. Aliases: !!@'
def process
# calculate user-given value
@ -16,5 +17,6 @@ class Pry
end
end
Pry::Commands.alias_command "!!@", "exit-all"
Pry::Commands.add_command(Pry::Command::ExitAll)
Pry::Commands.alias_command '!!@', 'exit-all'
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "exit-program" do
class Command::ExitProgram < Pry::ClassCommand
match 'exit-program'
group 'Navigating Pry'
description "End the current program. Aliases: quit-program, !!!"
description 'End the current program. Aliases: quit-program, !!!'
def process
Pry.save_history if Pry.config.history.should_save
@ -9,6 +10,7 @@ class Pry
end
end
Pry::Commands.alias_command "quit-program", "exit-program"
Pry::Commands.alias_command "!!!", "exit-program"
Pry::Commands.add_command(Pry::Command::ExitProgram)
Pry::Commands.alias_command 'quit-program', 'exit-program'
Pry::Commands.alias_command '!!!', 'exit-program'
end

View File

@ -1,13 +1,13 @@
class Pry
Pry::Commands.create_command "find-method" do
class Command::FindMethod < Pry::ClassCommand
extend Pry::Helpers::BaseHelpers
group "Context"
options :requires_gem => "ruby18_source_location" if mri_18?
match 'find-method'
group 'Context'
options :requires_gem => 'ruby18_source_location' if mri_18?
options :shellwords => false
description "Recursively search for a method within a Class/Module or the current namespace. find-method [-n | -c] METHOD [NAMESPACE]"
description 'Recursively search for a method within a Class/Module or the current namespace. find-method [-n | -c] METHOD [NAMESPACE]'
banner <<-BANNER
Usage: find-method [-n | -c] METHOD [NAMESPACE]
@ -162,4 +162,6 @@ class Pry
end
end
end
Pry::Commands.add_command(Pry::Command::FindMethod)
end

View File

@ -1,5 +1,6 @@
class Pry
Pry::Commands.create_command "gem-cd" do |gem|
class Command::GemCd < Pry::ClassCommand
match 'gem-cd'
group 'Gems'
description "Change working directory to specified gem's directory."
command_options :argument_required => true
@ -19,4 +20,6 @@ class Pry
gem_complete(str)
end
end
Pry::Commands.add_command(Pry::Command::GemCd)
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "gem-install" do |gem|
class Command::GemInstall < Pry::ClassCommand
match 'gem-install'
group 'Gems'
description "Install a gem and refresh the gem cache."
description 'Install a gem and refresh the gem cache.'
command_options :argument_required => true
banner <<-BANNER
@ -30,4 +31,6 @@ class Pry
end
end
end
Pry::Commands.add_command(Pry::Command::GemInstall)
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "gem-list" do |pattern|
class Command::GemList < Pry::ClassCommand
match 'gem-list'
group 'Gems'
description "List and search installed gems."
description 'List and search installed gems.'
banner <<-BANNER
Usage: gem-list [REGEX]
@ -10,7 +11,7 @@ class Pry
match the regex.
BANNER
def process(pattern=nil)
def process(pattern = nil)
pattern = Regexp.compile(pattern || '')
gems = gem_list(pattern).group_by(&:name)
@ -27,4 +28,6 @@ class Pry
end
end
end
Pry::Commands.add_command(Pry::Command::GemList)
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "gem-open" do |gem|
class Command::GemOpen < Pry::ClassCommand
match 'gem-open'
group 'Gems'
description "Opens the working directory of the gem in your editor"
description 'Opens the working directory of the gem in your editor'
command_options :argument_required => true
banner <<-BANNER
@ -21,4 +22,6 @@ class Pry
gem_complete(str)
end
end
Pry::Commands.add_command(Pry::Command::GemOpen)
end

View File

@ -28,9 +28,10 @@ class Pry
end
end
Pry::Commands.create_command "gist" do
class Command::Gist < Pry::ClassCommand
include Pry::Helpers::DocumentationHelpers
match 'gist'
group 'Misc'
description Pry::Gist::DESCRIPTION
command_options :requires_gem => 'jist', :shellwords => false
@ -192,6 +193,7 @@ class Pry
end
Pry::Commands.alias_command "clipit", "gist --clip"
Pry::Commands.alias_command "jist", "gist"
Pry::Commands.add_command(Pry::Command::Gist)
Pry::Commands.alias_command 'clipit', 'gist --clip'
Pry::Commands.alias_command 'jist', 'gist'
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "help" do |cmd|
class Command::Help < Pry::ClassCommand
match 'help'
group 'Help'
description "Show a list of commands. Type `help <foo>` for information about <foo>."
description 'Show a list of commands. Type `help <foo>` for information about <foo>.'
banner <<-BANNER
Usage: help [ COMMAND ]
@ -121,4 +122,6 @@ class Pry
[%w(Help Context Editing Introspection Input_and_output Navigating_pry Gems Basic Commands).index(group_name.gsub(' ', '_')) || 99, group_name]
end
end
Pry::Commands.add_command(Pry::Command::Help)
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "hist" do
group "Editing"
description "Show and replay Readline history. Aliases: history"
class Command::Hist < Pry::ClassCommand
match 'hist'
group 'Editing'
description 'Show and replay Readline history. Aliases: history'
banner <<-USAGE
Usage: hist
@ -153,5 +154,6 @@ class Pry
end
end
Pry::Commands.alias_command "history", "hist"
Pry::Commands.add_command(Pry::Command::Hist)
Pry::Commands.alias_command 'history', 'hist'
end

View File

@ -1,7 +1,10 @@
class Pry
Pry::Commands.create_command "import-set" do
group "Commands"
description "Import a command set."
class Command::ImportSet < Pry::ClassCommand
match 'import-set'
group 'Commands'
# TODO: Provide a better description with examples and a general conception
# of this command.
description 'Import a Pry command set.'
def process(command_set_name)
raise CommandError, "Provide a command set name" if command_set.nil?
@ -10,4 +13,6 @@ class Pry
_pry_.commands.import set
end
end
Pry::Commands.add_command(Pry::Command::ImportSet)
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "install-command" do
class Command::InstallCommand < Pry::ClassCommand
match 'install-command'
group 'Commands'
description "Install a disabled command."
description 'Install a disabled command.'
banner <<-BANNER
Usage: install-command COMMAND
@ -45,4 +46,6 @@ class Pry
output.puts "Installation of `#{name}` successful! Type `help #{name}` for information"
end
end
Pry::Commands.add_command(Pry::Command::InstallCommand)
end

View File

@ -1,8 +1,9 @@
class Pry
Pry::Commands.create_command "jump-to" do
class Command::JumpTo < Pry::ClassCommand
match 'jump-to'
group 'Navigating Pry'
description "Jump to a binding further up the stack, popping all " \
"bindings below."
description 'Jump to a binding further up the stack, popping all ' \
'bindings below.'
def process(break_level)
break_level = break_level.to_i
@ -20,4 +21,6 @@ class Pry
end
end
end
Pry::Commands.add_command(Pry::Command::JumpTo)
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "ls" do
group "Context"
description "Show the list of vars and methods in the current scope."
class Command::Ls < Pry::ClassCommand
match 'ls'
group 'Context'
description 'Show the list of vars and methods in the current scope.'
command_options :shellwords => false, :interpolate => false
def options(opt)
@ -320,4 +321,6 @@ class Pry
text.send(Pry.config.ls.send(:"#{type}_color"), str)
end
end
Pry::Commands.add_command(Pry::Command::Ls)
end

View File

@ -1,11 +1,12 @@
class Pry
Pry::Commands.create_command "nesting" do
class Command::Nesting < Pry::ClassCommand
match 'nesting'
group 'Navigating Pry'
description "Show nesting information."
description 'Show nesting information.'
def process
output.puts "Nesting status:"
output.puts "--"
output.puts 'Nesting status:'
output.puts '--'
_pry_.binding_stack.each_with_index do |obj, level|
if level == 0
output.puts "#{level}. #{Pry.view_clip(obj.eval('self'))} (Pry top level)"
@ -15,4 +16,6 @@ class Pry
end
end
end
Pry::Commands.add_command(Pry::Command::Nesting)
end

View File

@ -1,9 +1,10 @@
class Pry
Pry::Commands.create_command "play" do
class Command::Play < Pry::ClassCommand
include Pry::Helpers::DocumentationHelpers
match 'play'
group 'Editing'
description "Play back a string variable or a method or a file as input."
description 'Play back a string variable or a method or a file as input.'
banner <<-BANNER
Usage: play [OPTIONS] [--help]
@ -115,6 +116,7 @@ class Pry
self.content << File.read(_pry_.last_file)
self.content = restrict_to_lines(self.content, lines)
end
end
Pry::Commands.add_command(Pry::Command::Play)
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "pry-backtrace" do
class Command::PryBacktrace < Pry::ClassCommand
match 'pry-backtrace'
group 'Context'
description "Show the backtrace for the Pry session."
description 'Show the backtrace for the Pry session.'
banner <<-BANNER
Usage: pry-backtrace [OPTIONS] [--help]
@ -21,4 +22,6 @@ class Pry
stagger_output _pry_.backtrace.join("\n")
end
end
Pry::Commands.add_command(Pry::Command::PryBacktrace)
end

View File

@ -1,10 +1,13 @@
class Pry
Pry::Commands.create_command "pry-version" do
class Command::Version < Pry::ClassCommand
match 'pry-version'
group 'Misc'
description "Show Pry version."
description 'Show Pry version.'
def process
output.puts "Pry version: #{Pry::VERSION} on Ruby #{RUBY_VERSION}."
end
end
Pry::Commands.add_command(Pry::Command::Version)
end

View File

@ -1,8 +1,9 @@
class Pry
# N.B. using a regular expresion here so that "raise-up 'foo'" does the right thing.
Pry::Commands.create_command(/raise-up(!?\b.*)/) do
class Command::RaiseUp < Pry::ClassCommand
match /raise-up(!?\b.*)/
group 'Context'
description "Raise an exception out of the current pry instance."
description 'Raise an exception out of the current pry instance.'
command_options :listing => 'raise-up'
banner <<-BANNER
@ -23,4 +24,6 @@ class Pry
target.eval("_pry_.raise_up#{captures[0]}")
end
end
Pry::Commands.add_command(Pry::Command::RaiseUp)
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "reload-method" do
class Command::ReloadMethod < Pry::ClassCommand
match 'reload-method'
group 'Misc'
description "Reload the source file that contains the specified method"
description 'Reload the source file that contains the specified method'
def process(meth_name)
meth = get_method_or_raise(meth_name, target, {}, :omit_help)
@ -17,4 +18,6 @@ class Pry
end
end
end
Pry::Commands.add_command(Pry::Command::ReloadMethod)
end

View File

@ -1,11 +1,14 @@
class Pry
Pry::Commands.create_command "reset" do
class Command::Reset < Pry::ClassCommand
match 'reset'
group 'Context'
description "Reset the REPL to a clean state."
description 'Reset the REPL to a clean state.'
def process
output.puts "Pry reset."
exec "pry"
output.puts 'Pry reset.'
exec 'pry'
end
end
Pry::Commands.add_command(Pry::Command::Reset)
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "ri" do
class Command::Ri < Pry::ClassCommand
match 'ri'
group 'Introspection'
description "View ri documentation. e.g `ri Array#each`"
description 'View ri documentation. e.g `ri Array#each`'
banner <<-BANNER
Usage: ri [spec]
@ -48,4 +49,6 @@ class Pry
end
end
end
Pry::Commands.add_command(Pry::Command::Ri)
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "save-file" do
class Command::SaveFile < Pry::ClassCommand
match 'save-file'
group 'Input and Output'
description "Export to a file using content from the REPL."
description 'Export to a file using content from the REPL.'
banner <<-USAGE
Usage: save-file [OPTIONS] [FILE]
@ -96,4 +97,6 @@ class Pry
end
end
end
Pry::Commands.add_command(Pry::Command::SaveFile)
end

View File

@ -1,8 +1,9 @@
class Pry
Pry::Commands.create_command(/\.(.*)/) do
class Command::ShellCommand < Pry::ClassCommand
match /\.(.*)/
group 'Input and Output'
description "All text following a '.' is forwarded to the shell."
command_options :listing => ".<shell command>", :use_prefix => false,
command_options :listing => '.<shell command>', :use_prefix => false,
:takes_block => true
def process(cmd)
@ -28,4 +29,6 @@ class Pry
super + Bond::Rc.files(search.split(" ").last || '')
end
end
Pry::Commands.add_command(Pry::Command::ShellCommand)
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "shell-mode" do
class Command::ShellMode < Pry::ClassCommand
match 'shell-mode'
group 'Input and Output'
description "Toggle shell mode. Bring in pwd prompt and file completion."
description 'Toggle shell mode. Bring in pwd prompt and file completion.'
def process
case _pry_.prompt
@ -17,5 +18,6 @@ class Pry
end
end
Pry::Commands.alias_command "file-mode", "shell-mode"
Pry::Commands.add_command(Pry::Command::ShellMode)
Pry::Commands.alias_command 'file-mode', 'shell-mode'
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "show-command" do
class Command::ShowCommand < Pry::ClassCommand
match 'show-command'
group 'Introspection'
description "Show the source for CMD."
description 'Show the source for CMD.'
def process(*args)
target = target()
@ -19,4 +20,6 @@ class Pry
render_output opts.banner
end
end
Pry::Commands.add_command(Pry::Command::ShowCommand)
end

View File

@ -1,12 +1,13 @@
class Pry
Pry::Commands.create_command "show-doc" do
class Command::ShowDoc < Pry::ClassCommand
include Pry::Helpers::DocumentationHelpers
extend Pry::Helpers::BaseHelpers
match 'show-doc'
group 'Introspection'
description "Show the documentation for a method or class. Aliases: \?"
description 'Show the documentation for a method or class. Aliases: \?'
command_options :shellwords => false
command_options :requires_gem => "ruby18_source_location" if mri_18?
command_options :requires_gem => 'ruby18_source_location' if mri_18?
banner <<-BANNER
Usage: show-doc [OPTIONS] [METH]
@ -174,5 +175,6 @@ class Pry
end
end
Pry::Commands.alias_command "?", "show-doc"
Pry::Commands.add_command(Pry::Command::ShowDoc)
Pry::Commands.alias_command '?', 'show-doc'
end

View File

@ -1,10 +1,13 @@
class Pry
Pry::Commands.create_command "show-input" do
class Command::ShowInput < Pry::ClassCommand
match 'show-input'
group 'Editing'
description "Show the contents of the input buffer for the current multi-line expression."
description 'Show the contents of the input buffer for the current multi-line expression.'
def process
output.puts Code.new(eval_string).with_line_numbers
end
end
Pry::Commands.add_command(Pry::Command::ShowInput)
end

View File

@ -1,9 +1,10 @@
class Pry
Pry::Commands.create_command "show-source" do
class Command::ShowSource < Pry::ClassCommand
extend Pry::Helpers::BaseHelpers
match 'show-source'
group 'Introspection'
description "Show the source for a method or class. Aliases: $, show-method"
description 'Show the source for a method or class. Aliases: $, show-method'
banner <<-BANNER
Usage: show-source [OPTIONS] [METH|CLASS]
@ -130,6 +131,7 @@ class Pry
end
end
Pry::Commands.alias_command "show-method", "show-source"
Pry::Commands.alias_command "$", "show-source"
Pry::Commands.add_command(Pry::Command::ShowSource)
Pry::Commands.alias_command 'show-method', 'show-source'
Pry::Commands.alias_command '$', 'show-source'
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "simple-prompt" do
class Command::SimplePrompt < Pry::ClassCommand
match 'simple-prompt'
group 'Misc'
description "Toggle the simple prompt."
description 'Toggle the simple prompt.'
def process
case _pry_.prompt
@ -12,4 +13,6 @@ class Pry
end
end
end
Pry::Commands.add_command(Pry::Command::SimplePrompt)
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command "stat" do
class Command::Stat < Pry::ClassCommand
match 'stat'
group 'Introspection'
description "View method information and set _file_ and _dir_ locals."
description 'View method information and set _file_ and _dir_ locals.'
command_options :shellwords => false
banner <<-BANNER
@ -32,4 +33,6 @@ class Pry
EOS
end
end
Pry::Commands.add_command(Pry::Command::Stat)
end

View File

@ -1,8 +1,9 @@
class Pry
Pry::Commands.create_command "switch-to" do
class Command::SwitchTo < Pry::ClassCommand
match 'switch-to'
group 'Navigating Pry'
description "Start a new sub-session on a binding in the current stack " \
"(numbered by nesting)."
description 'Start a new subsession on a binding in the current stack ' \
'(numbered by nesting).'
def process(selection)
selection = selection.to_i
@ -14,4 +15,6 @@ class Pry
end
end
end
Pry::Commands.add_command(Pry::Command::SwitchTo)
end

View File

@ -1,11 +1,14 @@
class Pry
Pry::Commands.create_command "toggle-color" do
class Command::ToggleColor < Pry::ClassCommand
match 'toggle-color'
group 'Misc'
description "Toggle syntax highlighting."
description 'Toggle syntax highlighting.'
def process
Pry.color = !Pry.color
output.puts "Syntax highlighting #{Pry.color ? "on" : "off"}"
end
end
Pry::Commands.add_command(Pry::Command::ToggleColor)
end

View File

@ -1,7 +1,9 @@
class Pry
Pry::Commands.create_command "whereami" do
description "Show code surrounding the current context."
class Command::Whereami < Pry::ClassCommand
match 'whereami'
description 'Show code surrounding the current context.'
group 'Context'
banner <<-BANNER
Usage: whereami [-q] [N]
@ -84,4 +86,6 @@ class Pry
end
end
end
Pry::Commands.add_command(Pry::Command::Whereami)
end

View File

@ -1,7 +1,8 @@
class Pry
Pry::Commands.create_command(/wtf([?!]*)/) do
class Command::Wtf < Pry::ClassCommand
match /wtf([?!]*)/
group 'Context'
description "Show the backtrace of the most recent exception"
description 'Show the backtrace of the most recent exception'
options :listing => 'wtf?'
banner <<-BANNER
@ -35,4 +36,6 @@ class Pry
end
end
end
Pry::Commands.add_command(Pry::Command::Wtf)
end