pry 0.10.0.pre4-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +702 -0
  3. data/LICENSE +25 -0
  4. data/README.md +406 -0
  5. data/bin/pry +16 -0
  6. data/lib/pry.rb +161 -0
  7. data/lib/pry/cli.rb +220 -0
  8. data/lib/pry/code.rb +341 -0
  9. data/lib/pry/code/code_file.rb +103 -0
  10. data/lib/pry/code/code_range.rb +71 -0
  11. data/lib/pry/code/loc.rb +92 -0
  12. data/lib/pry/code_object.rb +172 -0
  13. data/lib/pry/color_printer.rb +55 -0
  14. data/lib/pry/command.rb +692 -0
  15. data/lib/pry/command_set.rb +443 -0
  16. data/lib/pry/commands.rb +6 -0
  17. data/lib/pry/commands/amend_line.rb +99 -0
  18. data/lib/pry/commands/bang.rb +20 -0
  19. data/lib/pry/commands/bang_pry.rb +17 -0
  20. data/lib/pry/commands/cat.rb +62 -0
  21. data/lib/pry/commands/cat/abstract_formatter.rb +27 -0
  22. data/lib/pry/commands/cat/exception_formatter.rb +77 -0
  23. data/lib/pry/commands/cat/file_formatter.rb +67 -0
  24. data/lib/pry/commands/cat/input_expression_formatter.rb +43 -0
  25. data/lib/pry/commands/cd.rb +41 -0
  26. data/lib/pry/commands/change_inspector.rb +27 -0
  27. data/lib/pry/commands/change_prompt.rb +26 -0
  28. data/lib/pry/commands/code_collector.rb +165 -0
  29. data/lib/pry/commands/disable_pry.rb +27 -0
  30. data/lib/pry/commands/disabled_commands.rb +2 -0
  31. data/lib/pry/commands/easter_eggs.rb +112 -0
  32. data/lib/pry/commands/edit.rb +195 -0
  33. data/lib/pry/commands/edit/exception_patcher.rb +25 -0
  34. data/lib/pry/commands/edit/file_and_line_locator.rb +36 -0
  35. data/lib/pry/commands/exit.rb +42 -0
  36. data/lib/pry/commands/exit_all.rb +29 -0
  37. data/lib/pry/commands/exit_program.rb +23 -0
  38. data/lib/pry/commands/find_method.rb +193 -0
  39. data/lib/pry/commands/fix_indent.rb +19 -0
  40. data/lib/pry/commands/gem_cd.rb +26 -0
  41. data/lib/pry/commands/gem_install.rb +32 -0
  42. data/lib/pry/commands/gem_list.rb +33 -0
  43. data/lib/pry/commands/gem_open.rb +29 -0
  44. data/lib/pry/commands/gist.rb +101 -0
  45. data/lib/pry/commands/help.rb +164 -0
  46. data/lib/pry/commands/hist.rb +180 -0
  47. data/lib/pry/commands/import_set.rb +22 -0
  48. data/lib/pry/commands/install_command.rb +53 -0
  49. data/lib/pry/commands/jump_to.rb +29 -0
  50. data/lib/pry/commands/list_inspectors.rb +35 -0
  51. data/lib/pry/commands/list_prompts.rb +35 -0
  52. data/lib/pry/commands/ls.rb +114 -0
  53. data/lib/pry/commands/ls/constants.rb +47 -0
  54. data/lib/pry/commands/ls/formatter.rb +49 -0
  55. data/lib/pry/commands/ls/globals.rb +48 -0
  56. data/lib/pry/commands/ls/grep.rb +21 -0
  57. data/lib/pry/commands/ls/instance_vars.rb +39 -0
  58. data/lib/pry/commands/ls/interrogatable.rb +18 -0
  59. data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
  60. data/lib/pry/commands/ls/local_names.rb +35 -0
  61. data/lib/pry/commands/ls/local_vars.rb +39 -0
  62. data/lib/pry/commands/ls/ls_entity.rb +70 -0
  63. data/lib/pry/commands/ls/methods.rb +57 -0
  64. data/lib/pry/commands/ls/methods_helper.rb +46 -0
  65. data/lib/pry/commands/ls/self_methods.rb +32 -0
  66. data/lib/pry/commands/nesting.rb +25 -0
  67. data/lib/pry/commands/play.rb +103 -0
  68. data/lib/pry/commands/pry_backtrace.rb +25 -0
  69. data/lib/pry/commands/pry_version.rb +17 -0
  70. data/lib/pry/commands/raise_up.rb +32 -0
  71. data/lib/pry/commands/reload_code.rb +62 -0
  72. data/lib/pry/commands/reset.rb +18 -0
  73. data/lib/pry/commands/ri.rb +60 -0
  74. data/lib/pry/commands/save_file.rb +61 -0
  75. data/lib/pry/commands/shell_command.rb +48 -0
  76. data/lib/pry/commands/shell_mode.rb +25 -0
  77. data/lib/pry/commands/show_doc.rb +83 -0
  78. data/lib/pry/commands/show_info.rb +195 -0
  79. data/lib/pry/commands/show_input.rb +17 -0
  80. data/lib/pry/commands/show_source.rb +50 -0
  81. data/lib/pry/commands/simple_prompt.rb +22 -0
  82. data/lib/pry/commands/stat.rb +40 -0
  83. data/lib/pry/commands/switch_to.rb +23 -0
  84. data/lib/pry/commands/toggle_color.rb +24 -0
  85. data/lib/pry/commands/watch_expression.rb +105 -0
  86. data/lib/pry/commands/watch_expression/expression.rb +38 -0
  87. data/lib/pry/commands/whereami.rb +190 -0
  88. data/lib/pry/commands/wtf.rb +57 -0
  89. data/lib/pry/config.rb +24 -0
  90. data/lib/pry/config/behavior.rb +139 -0
  91. data/lib/pry/config/convenience.rb +26 -0
  92. data/lib/pry/config/default.rb +165 -0
  93. data/lib/pry/core_extensions.rb +131 -0
  94. data/lib/pry/editor.rb +133 -0
  95. data/lib/pry/exceptions.rb +77 -0
  96. data/lib/pry/helpers.rb +5 -0
  97. data/lib/pry/helpers/base_helpers.rb +113 -0
  98. data/lib/pry/helpers/command_helpers.rb +156 -0
  99. data/lib/pry/helpers/documentation_helpers.rb +75 -0
  100. data/lib/pry/helpers/options_helpers.rb +27 -0
  101. data/lib/pry/helpers/table.rb +109 -0
  102. data/lib/pry/helpers/text.rb +107 -0
  103. data/lib/pry/history.rb +125 -0
  104. data/lib/pry/history_array.rb +121 -0
  105. data/lib/pry/hooks.rb +230 -0
  106. data/lib/pry/indent.rb +406 -0
  107. data/lib/pry/input_completer.rb +242 -0
  108. data/lib/pry/input_lock.rb +132 -0
  109. data/lib/pry/inspector.rb +27 -0
  110. data/lib/pry/last_exception.rb +61 -0
  111. data/lib/pry/method.rb +546 -0
  112. data/lib/pry/method/disowned.rb +53 -0
  113. data/lib/pry/method/patcher.rb +125 -0
  114. data/lib/pry/method/weird_method_locator.rb +186 -0
  115. data/lib/pry/module_candidate.rb +136 -0
  116. data/lib/pry/object_path.rb +82 -0
  117. data/lib/pry/output.rb +50 -0
  118. data/lib/pry/pager.rb +234 -0
  119. data/lib/pry/plugins.rb +103 -0
  120. data/lib/pry/prompt.rb +26 -0
  121. data/lib/pry/pry_class.rb +375 -0
  122. data/lib/pry/pry_instance.rb +654 -0
  123. data/lib/pry/rbx_path.rb +22 -0
  124. data/lib/pry/repl.rb +202 -0
  125. data/lib/pry/repl_file_loader.rb +74 -0
  126. data/lib/pry/rubygem.rb +82 -0
  127. data/lib/pry/terminal.rb +79 -0
  128. data/lib/pry/test/helper.rb +170 -0
  129. data/lib/pry/version.rb +3 -0
  130. data/lib/pry/wrapped_module.rb +373 -0
  131. metadata +248 -0
@@ -0,0 +1,27 @@
1
+ class Pry
2
+ class Command::DisablePry < Pry::ClassCommand
3
+ match 'disable-pry'
4
+ group 'Navigating Pry'
5
+ description 'Stops all future calls to pry and exits the current session.'
6
+
7
+ banner <<-'BANNER'
8
+ Usage: disable-pry
9
+
10
+ After this command is run any further calls to pry will immediately return `nil`
11
+ without interrupting the flow of your program. This is particularly useful when
12
+ you've debugged the problem you were having, and now wish the program to run to
13
+ the end.
14
+
15
+ As alternatives, consider using `exit!` to force the current Ruby process
16
+ to quit immediately; or using `edit-method -p` to remove the `binding.pry`
17
+ from the code.
18
+ BANNER
19
+
20
+ def process
21
+ ENV['DISABLE_PRY'] = 'true'
22
+ _pry_.run_command "exit"
23
+ end
24
+ end
25
+
26
+ Pry::Commands.add_command(Pry::Command::DisablePry)
27
+ end
@@ -0,0 +1,2 @@
1
+ Pry::Commands.disabled_command("edit-method", "Use `edit` instead.")
2
+ Pry::Commands.disabled_command("show-command", "Use show-source [command_name] instead.")
@@ -0,0 +1,112 @@
1
+ class Pry
2
+ Pry::Commands.instance_eval do
3
+ command "nyan-cat", "", :requires_gem => ["nyancat"] do
4
+ run ".nyancat"
5
+ end
6
+
7
+ command(/!s\/(.*?)\/(.*?)/, "") do |source, dest|
8
+ eval_string.gsub!(/#{source}/) { dest }
9
+ run "show-input"
10
+ end
11
+
12
+ command "get-naked", "" do
13
+ text = %{
14
+ --
15
+ We dont have to take our clothes off to have a good time.
16
+ We could dance & party all night And drink some cherry wine.
17
+ -- Jermaine Stewart }
18
+ output.puts text
19
+ text
20
+ end
21
+
22
+ command "east-coker", "" do
23
+ text = %{
24
+ --
25
+ Now the light falls
26
+ Across the open field, leaving the deep lane
27
+ Shuttered with branches, dark in the afternoon,
28
+ Where you lean against a bank while a van passes,
29
+ And the deep lane insists on the direction
30
+ Into the village, in the electric heat
31
+ Hypnotised. In a warm haze the sultry light
32
+ Is absorbed, not refracted, by grey stone.
33
+ The dahlias sleep in the empty silence.
34
+ Wait for the early owl.
35
+ -- T.S Eliot
36
+ }
37
+ output.puts text
38
+ text
39
+ end
40
+
41
+ command "cohen-poem", "" do
42
+ text = %{
43
+ --
44
+ When this American woman,
45
+ whose thighs are bound in casual red cloth,
46
+ comes thundering past my sitting place
47
+ like a forest-burning Mongol tribe,
48
+ the city is ravished
49
+ and brittle buildings of a hundred years
50
+ splash into the street;
51
+ and my eyes are burnt
52
+ for the embroidered Chinese girls,
53
+ already old,
54
+ and so small between the thin pines
55
+ on these enormous landscapes,
56
+ that if you turn your head
57
+ they are lost for hours.
58
+ -- Leonard Cohen
59
+ }
60
+ output.puts text
61
+ text
62
+ end
63
+
64
+ command "pessoa-poem", "" do
65
+ output.puts <<-TEXT
66
+ --
67
+ I've gone to bed with every feeling,
68
+ I've been the pimp of every emotion,
69
+ All felt sensations have bought me drinks,
70
+ I've traded glances with every motive for every act,
71
+ I've held hands with every urge to depart,
72
+ ..
73
+ Rage, foam, the vastness that doesn't fit in my handkerchief,
74
+ The dog in heat howling in the night,
75
+ The pond from the farm going in circles around my insomnia,
76
+ The woods as they were, on our late-afternoon walks, the rose,
77
+ The indifferent tuft of hair, the moss, the pines,
78
+ The rage of not containing all this, not retaining all this,
79
+ O abstract hunger for things, impotent libido for moments,
80
+ Intellectual orgy of feeling life!
81
+ -- Fernando Pessoa
82
+ TEXT
83
+ end
84
+
85
+ command "test-ansi", "" do
86
+ prev_color = _pry_.config.color
87
+ _pry_.config.color = true
88
+
89
+ picture = unindent <<-'EOS'.gsub(/[[:alpha:]!]/) { |s| text.red(s) }
90
+ ____ _______________________
91
+ / \ | A W G |
92
+ / O O \ | N I O N ! |
93
+ | | | S S R I ! |
94
+ \ \__/ / __| I K ! |
95
+ \____/ \________________________|
96
+ EOS
97
+
98
+ if windows_ansi?
99
+ move_up = proc { |n| "\e[#{n}F" }
100
+ else
101
+ move_up = proc { |n| "\e[#{n}A\e[0G" }
102
+ end
103
+
104
+ output.puts "\n" * 6
105
+ output.puts picture.lines.map(&:chomp).reverse.join(move_up[1])
106
+ output.puts "\n" * 6
107
+ output.puts "** ENV['TERM'] is #{ENV['TERM']} **\n\n"
108
+
109
+ _pry_.config.color = prev_color
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,195 @@
1
+ class Pry
2
+ class Command::Edit < Pry::ClassCommand
3
+ require 'pry/commands/edit/exception_patcher'
4
+ require 'pry/commands/edit/file_and_line_locator'
5
+
6
+ match 'edit'
7
+ group 'Editing'
8
+ description 'Invoke the default editor on a file.'
9
+
10
+ banner <<-'BANNER'
11
+ Usage: edit [--no-reload|--reload|--patch] [--line LINE] [--temp|--ex|FILE[:LINE]|OBJECT|--in N]
12
+
13
+ Open a text editor. When no FILE is given, edits the pry input buffer.
14
+ When a method/module/command is given, the code is opened in an editor.
15
+ Ensure `Pry.config.editor` or `_pry_.config.editor` is set to your editor of choice.
16
+
17
+ edit sample.rb edit -p MyClass#my_method
18
+ edit sample.rb --line 105 edit MyClass
19
+ edit MyClass#my_method edit --ex
20
+ edit --method edit --ex -p
21
+
22
+ https://github.com/pry/pry/wiki/Editor-integration#wiki-Edit_command
23
+ BANNER
24
+
25
+ def options(opt)
26
+ opt.on :e, :ex, "Open the file that raised the most recent exception (_ex_.file)",
27
+ :optional_argument => true, :as => Integer
28
+ opt.on :i, :in, "Open a temporary file containing the Nth input expression. N may be a range",
29
+ :optional_argument => true, :as => Range, :default => -1..-1
30
+ opt.on :t, :temp, "Open an empty temporary file"
31
+ opt.on :l, :line, "Jump to this line in the opened file",
32
+ :argument => true, :as => Integer
33
+ opt.on :n, :"no-reload", "Don't automatically reload the edited file"
34
+ opt.on :c, :current, "Open the current __FILE__ and at __LINE__ (as returned by `whereami`)"
35
+ opt.on :r, :reload, "Reload the edited code immediately (default for ruby files)"
36
+ opt.on :p, :patch, "Instead of editing the object's file, try to edit in a tempfile and apply as a monkey patch"
37
+ opt.on :m, :method, "Explicitly edit the _current_ method (when inside a method context)."
38
+ end
39
+
40
+ def process
41
+ if bad_option_combination?
42
+ raise CommandError, "Only one of --ex, --temp, --in, --method and FILE may be specified."
43
+ end
44
+
45
+ if repl_edit?
46
+ # code defined in pry, eval'd within pry.
47
+ repl_edit
48
+ elsif runtime_patch?
49
+ # patch code without persisting changes
50
+ apply_runtime_patch
51
+ else
52
+ # code stored in actual files, eval'd at top-level
53
+ file_edit
54
+ end
55
+ end
56
+
57
+ def repl_edit?
58
+ !opts.present?(:ex) && !opts.present?(:current) && !opts.present?(:method) &&
59
+ filename_argument.empty?
60
+ end
61
+
62
+ def repl_edit
63
+ content = Pry::Editor.new(_pry_).edit_tempfile_with_content(initial_temp_file_content,
64
+ initial_temp_file_content.lines.count)
65
+ silence_warnings do
66
+ eval_string.replace content
67
+ end
68
+ end
69
+
70
+ def file_based_exception?
71
+ opts.present?(:ex) && !opts.present?(:patch)
72
+ end
73
+
74
+ def runtime_patch?
75
+ !file_based_exception? && (opts.present?(:patch) || pry_method?(code_object))
76
+ end
77
+
78
+ def apply_runtime_patch
79
+ if patch_exception?
80
+ ExceptionPatcher.new(_pry_, state, file_and_line_for_current_exception).perform_patch
81
+ else
82
+ if code_object.is_a?(Pry::Method)
83
+ code_object.redefine Pry::Editor.new(_pry_).edit_tempfile_with_content(code_object.source)
84
+ else
85
+ raise NotImplementedError, "Cannot yet patch #{code_object} objects!"
86
+ end
87
+ end
88
+ end
89
+
90
+ def ensure_file_name_is_valid(file_name)
91
+ raise CommandError, "Cannot find a valid file for #{filename_argument}" if !file_name
92
+ raise CommandError, "#{file_name} is not a valid file name, cannot edit!" if not_a_real_file?(file_name)
93
+ end
94
+
95
+ def file_and_line_for_current_exception
96
+ FileAndLineLocator.from_exception(_pry_.last_exception, opts[:ex].to_i)
97
+ end
98
+
99
+ def file_and_line
100
+ file_name, line = if opts.present?(:current)
101
+ FileAndLineLocator.from_binding(target)
102
+ elsif opts.present?(:ex)
103
+ file_and_line_for_current_exception
104
+ elsif code_object
105
+ FileAndLineLocator.from_code_object(code_object, filename_argument)
106
+ else
107
+ # when file and line are passed as a single arg, e.g my_file.rb:30
108
+ FileAndLineLocator.from_filename_argument(filename_argument)
109
+ end
110
+
111
+ [file_name, opts.present?(:line) ? opts[:l].to_i : line]
112
+ end
113
+
114
+ def file_edit
115
+ file_name, line = file_and_line
116
+
117
+ ensure_file_name_is_valid(file_name)
118
+
119
+ Pry::Editor.new(_pry_).invoke_editor(file_name, line, reload?(file_name))
120
+ set_file_and_dir_locals(file_name)
121
+
122
+ if reload?(file_name)
123
+ silence_warnings do
124
+ load file_name
125
+ end
126
+ end
127
+ end
128
+
129
+ def filename_argument
130
+ args.join(' ')
131
+ end
132
+
133
+ def code_object
134
+ @code_object ||= !probably_a_file?(filename_argument) &&
135
+ Pry::CodeObject.lookup(filename_argument, _pry_)
136
+ end
137
+
138
+ def pry_method?(code_object)
139
+ code_object.is_a?(Pry::Method) &&
140
+ code_object.pry_method?
141
+ end
142
+
143
+ def patch_exception?
144
+ opts.present?(:ex) && opts.present?(:patch)
145
+ end
146
+
147
+ def bad_option_combination?
148
+ [opts.present?(:ex), opts.present?(:temp),
149
+ opts.present?(:in), opts.present?(:method), !filename_argument.empty?].count(true) > 1
150
+ end
151
+
152
+ def input_expression
153
+ case opts[:i]
154
+ when Range
155
+ (_pry_.input_array[opts[:i]] || []).join
156
+ when Fixnum
157
+ _pry_.input_array[opts[:i]] || ""
158
+ else
159
+ raise Pry::CommandError, "Not a valid range: #{opts[:i]}"
160
+ end
161
+ end
162
+
163
+ def reloadable?
164
+ opts.present?(:reload) || opts.present?(:ex)
165
+ end
166
+
167
+ def never_reload?
168
+ opts.present?(:'no-reload') || _pry_.config.disable_auto_reload
169
+ end
170
+
171
+ def reload?(file_name="")
172
+ (reloadable? || file_name.end_with?(".rb")) && !never_reload?
173
+ end
174
+
175
+ def initial_temp_file_content
176
+ case
177
+ when opts.present?(:temp)
178
+ ""
179
+ when opts.present?(:in)
180
+ input_expression
181
+ when eval_string.strip != ""
182
+ eval_string
183
+ else
184
+ _pry_.input_array.reverse_each.find { |x| x && x.strip != "" } || ""
185
+ end
186
+ end
187
+
188
+ def probably_a_file?(str)
189
+ [".rb", ".c", ".py", ".yml", ".gemspec"].include?(File.extname(str)) ||
190
+ str =~ /\/|\\/
191
+ end
192
+ end
193
+
194
+ Pry::Commands.add_command(Pry::Command::Edit)
195
+ end
@@ -0,0 +1,25 @@
1
+ class Pry
2
+ class Command::Edit
3
+ class ExceptionPatcher
4
+ attr_accessor :_pry_
5
+ attr_accessor :state
6
+ attr_accessor :file_and_line
7
+
8
+ def initialize(_pry_, state, exception_file_and_line)
9
+ @_pry_ = _pry_
10
+ @state = state
11
+ @file_and_line = exception_file_and_line
12
+ end
13
+
14
+ # perform the patch
15
+ def perform_patch
16
+ file_name, _ = file_and_line
17
+ lines = state.dynamical_ex_file || File.read(file_name)
18
+
19
+ source = Pry::Editor.new(_pry_).edit_tempfile_with_content(lines)
20
+ _pry_.evaluate_ruby source
21
+ state.dynamical_ex_file = source.split("\n")
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,36 @@
1
+ class Pry
2
+ class Command::Edit
3
+ module FileAndLineLocator
4
+ class << self
5
+ def from_binding(target)
6
+ [target.eval("__FILE__"), target.eval("__LINE__")]
7
+ end
8
+
9
+ def from_code_object(code_object, filename_argument)
10
+ if File.exists?(code_object.source_file.to_s)
11
+ [code_object.source_file, code_object.source_line]
12
+ else
13
+ raise CommandError, "Cannot find a file for #{filename_argument}!"
14
+ end
15
+ end
16
+
17
+ def from_exception(exception, backtrace_level)
18
+ raise CommandError, "No exception found." if exception.nil?
19
+
20
+ file_name, line = exception.bt_source_location_for(backtrace_level)
21
+ raise CommandError, "Exception has no associated file." if file_name.nil?
22
+ raise CommandError, "Cannot edit exceptions raised in REPL." if Pry.eval_path == file_name
23
+
24
+ [file_name, line]
25
+ end
26
+
27
+ # when file and line are passed as a single arg, e.g my_file.rb:30
28
+ def from_filename_argument(filename_argument)
29
+ f = File.expand_path(filename_argument)
30
+ l = f.sub!(/:(\d+)$/, "") ? $1.to_i : 1
31
+ [f, l]
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,42 @@
1
+ class Pry
2
+ class Command::Exit < Pry::ClassCommand
3
+ match 'exit'
4
+ group 'Navigating Pry'
5
+ description 'Pop the previous binding.'
6
+ command_options :keep_retval => true
7
+
8
+ banner <<-'BANNER'
9
+ Usage: exit [OPTIONS] [--help]
10
+ Aliases: quit
11
+
12
+ Pop the previous binding (does NOT exit program). It can be useful to exit a
13
+ context with a user-provided value. For instance an exit value can be used to
14
+ determine program flow.
15
+
16
+ exit "pry this"
17
+ exit
18
+
19
+ https://github.com/pry/pry/wiki/State-navigation#wiki-Exit_with_value
20
+ BANNER
21
+
22
+ def process
23
+ if _pry_.binding_stack.one?
24
+ _pry_.run_command "exit-all #{arg_string}"
25
+ else
26
+ # otherwise just pop a binding and return user supplied value
27
+ process_pop_and_return
28
+ end
29
+ end
30
+
31
+ def process_pop_and_return
32
+ popped_object = _pry_.binding_stack.pop.eval('self')
33
+
34
+ # return a user-specified value if given otherwise return the object
35
+ return target.eval(arg_string) unless arg_string.empty?
36
+ popped_object
37
+ end
38
+ end
39
+
40
+ Pry::Commands.add_command(Pry::Command::Exit)
41
+ Pry::Commands.alias_command 'quit', 'exit'
42
+ end
@@ -0,0 +1,29 @@
1
+ class Pry
2
+ class Command::ExitAll < Pry::ClassCommand
3
+ match 'exit-all'
4
+ group 'Navigating Pry'
5
+ description 'End the current Pry session.'
6
+
7
+ banner <<-'BANNER'
8
+ Usage: exit-all [--help]
9
+ Aliases: !!@
10
+
11
+ End the current Pry session (popping all bindings and returning to caller).
12
+ Accepts optional return value.
13
+ BANNER
14
+
15
+ def process
16
+ # calculate user-given value
17
+ exit_value = target.eval(arg_string)
18
+
19
+ # clear the binding stack
20
+ _pry_.binding_stack.clear
21
+
22
+ # break out of the repl loop
23
+ throw(:breakout, exit_value)
24
+ end
25
+ end
26
+
27
+ Pry::Commands.add_command(Pry::Command::ExitAll)
28
+ Pry::Commands.alias_command '!!@', 'exit-all'
29
+ end