pry 0.10.4-java → 0.11.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +52 -18
- data/LICENSE +1 -1
- data/README.md +32 -31
- data/bin/pry +3 -7
- data/lib/pry.rb +4 -4
- data/lib/pry/basic_object.rb +6 -0
- data/lib/pry/cli.rb +39 -34
- data/lib/pry/code.rb +6 -1
- data/lib/pry/code/code_file.rb +8 -2
- data/lib/pry/code_object.rb +23 -0
- data/lib/pry/color_printer.rb +20 -11
- data/lib/pry/command.rb +40 -16
- data/lib/pry/command_set.rb +9 -2
- data/lib/pry/commands/cat/exception_formatter.rb +11 -10
- data/lib/pry/commands/cat/file_formatter.rb +7 -3
- data/lib/pry/commands/code_collector.rb +16 -14
- data/lib/pry/commands/easter_eggs.rb +9 -9
- data/lib/pry/commands/edit.rb +7 -3
- data/lib/pry/commands/edit/file_and_line_locator.rb +1 -1
- data/lib/pry/commands/find_method.rb +1 -1
- data/lib/pry/commands/gem_open.rb +1 -1
- data/lib/pry/commands/gem_readme.rb +25 -0
- data/lib/pry/commands/gem_search.rb +40 -0
- data/lib/pry/commands/hist.rb +2 -2
- data/lib/pry/commands/jump_to.rb +7 -7
- data/lib/pry/commands/ls.rb +3 -1
- data/lib/pry/commands/ls/constants.rb +12 -1
- data/lib/pry/commands/ls/formatter.rb +1 -0
- data/lib/pry/commands/ls/jruby_hacks.rb +2 -2
- data/lib/pry/commands/ls/self_methods.rb +2 -0
- data/lib/pry/commands/play.rb +2 -2
- data/lib/pry/commands/reload_code.rb +2 -2
- data/lib/pry/commands/ri.rb +4 -0
- data/lib/pry/commands/shell_command.rb +34 -8
- data/lib/pry/commands/show_info.rb +10 -2
- data/lib/pry/commands/watch_expression/expression.rb +1 -1
- data/lib/pry/commands/whereami.rb +7 -6
- data/lib/pry/config.rb +3 -16
- data/lib/pry/config/behavior.rb +140 -49
- data/lib/pry/config/default.rb +21 -33
- data/lib/pry/config/memoization.rb +44 -0
- data/lib/pry/core_extensions.rb +12 -2
- data/lib/pry/editor.rb +1 -1
- data/lib/pry/exceptions.rb +1 -1
- data/lib/pry/forwardable.rb +23 -0
- data/lib/pry/helpers/base_helpers.rb +6 -10
- data/lib/pry/helpers/documentation_helpers.rb +1 -0
- data/lib/pry/helpers/options_helpers.rb +1 -1
- data/lib/pry/helpers/text.rb +69 -75
- data/lib/pry/history.rb +22 -1
- data/lib/pry/history_array.rb +1 -1
- data/lib/pry/hooks.rb +48 -107
- data/lib/pry/indent.rb +6 -2
- data/lib/pry/input_completer.rb +138 -120
- data/lib/pry/last_exception.rb +2 -2
- data/lib/pry/method.rb +15 -15
- data/lib/pry/method/disowned.rb +1 -0
- data/lib/pry/method/patcher.rb +0 -3
- data/lib/pry/output.rb +37 -38
- data/lib/pry/pager.rb +11 -8
- data/lib/pry/plugins.rb +20 -5
- data/lib/pry/pry_class.rb +30 -4
- data/lib/pry/pry_instance.rb +8 -6
- data/lib/pry/repl.rb +38 -8
- data/lib/pry/repl_file_loader.rb +1 -1
- data/lib/pry/rubygem.rb +3 -1
- data/lib/pry/slop.rb +661 -0
- data/lib/pry/slop/LICENSE +20 -0
- data/lib/pry/slop/commands.rb +196 -0
- data/lib/pry/slop/option.rb +208 -0
- data/lib/pry/terminal.rb +16 -5
- data/lib/pry/test/helper.rb +12 -3
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +7 -7
- data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +7 -13
- metadata +14 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5929b7f4d236512da2e03bc50270cd4fc6c9b2b
|
4
|
+
data.tar.gz: 4576abab2169c70a2b7a156a69773e6ca5412af0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b034eb8f0ed3a69ee772e4d173e790d44d424a8a17e139440520b04a971a8c1ddf475c935d374e35cddcc9d50e1ff46b4b612cbb2773337fc79ada870830df7d
|
7
|
+
data.tar.gz: c1599009f2077755538bb189b6a5bd47baf28611efc612b5039411a10042f9995dad3d5c3dfb48715e8c244781e892377560005e75bb174ab2c5316fba8839f2
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,45 @@
|
|
1
|
-
###
|
2
|
-
|
3
|
-
*
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
*
|
8
|
-
*
|
1
|
+
### HEAD
|
2
|
+
|
3
|
+
* Add alias 'whereami[?!]+' for 'whereami' command. ([#1597](https://github.com/pry/pry/pull/1597))
|
4
|
+
* Improve Ruby 2.4 support ([#1611](https://github.com/pry/pry/pull/1611)):
|
5
|
+
* Deprecated constants are hidden from `ls` output by default, use the `-d` switch to see them.
|
6
|
+
* Fix warnings that originate in Pry while using the repl.
|
7
|
+
* Improve completion speed in large applications. ([#1588](https://github.com/pry/pry/pull/1588))
|
8
|
+
* Pry::ColorPrinter.pp: add `newline` argument and pass it on to PP. ([#1603](https://github.com/pry/pry/pull/1603))
|
9
|
+
* Use `less` or system pager pager on MS Windows if it is available. ([#1512](https://github.com/pry/pry/pull/1512))
|
10
|
+
* Add `Pry.configure` as an alternative to the current way of changing configuration options in `.pryrc` files. ([#1502](https://github.com/pry/pry/pull/1502))
|
11
|
+
* Add `Pry::Config::Behavior#eager_load!` to add a possible workaround for issues like ([#1501](https://github.com/pry/pry/issues/1501))
|
12
|
+
* Remove Slop as a runtime dependency by vendoring v3.4 as Pry::Slop.
|
13
|
+
People can depend on Slop v4 and Pry at the same time without running into version conflicts. ([#1497](https://github.com/pry/pry/issues/1497))
|
14
|
+
* Fix auto-indentation of code that uses a single-line rescue ([#1450](https://github.com/pry/pry/issues/1450))
|
15
|
+
* Remove "Pry::Config#refresh", please use "Pry::Config#clear" instead.
|
16
|
+
* Defining a method called "ls" no longer breaks the "ls" command ([#1407](https://github.com/pry/pry/issues/1407))
|
17
|
+
* Don't raise when directory permissions don't allow file expansion ([#1432](https://github.com/pry/pry/issues/1432))
|
18
|
+
* Syntax highlight <tt> tags in documentation output.
|
19
|
+
* Add support for BasicObject subclasses who implement their own #inspect (#1341)
|
20
|
+
* Fix 'include RSpec::Matchers' at the top-level (#1277)
|
21
|
+
* Add 'gem-readme' command, prints the README file bundled with a rubygem
|
22
|
+
* Add 'gem-search' command, searches for a gem with the rubygems.org HTTP API
|
23
|
+
* Fixed bug in the `cat` command where it was impossible to use line numbers with files ([#1349](https://github.com/pry/pry/issues/1349))
|
24
|
+
* Fixed uncaught Errno::EOPNOTSUPP exception when $stdout is a socket ([#1352](https://github.com/pry/pry/issues/1352))
|
25
|
+
* Display a warning when you cd'ed inside a C object and executed 'show-source' without arguments ([#691](https://github.com/pry/pry/issues/691))
|
26
|
+
* Make the stagger_output method more reliable by reusing possibly available Pry instance ([#1364](https://github.com/pry/pry/pull/1364))
|
27
|
+
* Make the 'gem-install' message less confusing by removing backticks ([#1350](https://github.com/pry/pry/pull/1350))
|
28
|
+
* Fixed error when Pry was trying to load incompatible versions of plugins ([#1312](https://github.com/pry/pry/issues/1312))
|
29
|
+
* Fixed bug when `hist --clear` led to ArgumentError ([#1340](https://github.com/pry/pry/pull/1340))
|
30
|
+
* Fixed the "uninitialized constant Pry::ObjectPath::StringScanner" exception during autocomplete ([#1330](https://github.com/pry/pry/issues/1330))
|
31
|
+
* Secured usage of colours with special characters (RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE) in Pry::Helpers::Text ([#493](https://github.com/pry/pry/issues/493#issuecomment-39232771))
|
32
|
+
* Fixed regression with `pry -e` when it messes the terminal ([#1387](https://github.com/pry/pry/issues/1387))
|
33
|
+
* Fixed regression with space prefixes of expressions ([#1369](https://github.com/pry/pry/issues/1369))
|
34
|
+
* Introduced the new way to define hooks for commands (with `Pry.hooks.add_hook("{before,after}_commandName")`). The old way is deprecated, but still supported (with `Pry.commands.{before,after}_command`) ([#651](https://github.com/pry/pry/issues/651))
|
35
|
+
* Removed old API's using `Pry::Hooks.from_hash` altogether
|
36
|
+
* Removed hints on Foreman support (see [this](https://github.com/ddollar/foreman/pull/536))
|
37
|
+
* Fixed support for the tee command ([#1334](https://github.com/pry/pry/issues/1334))
|
38
|
+
* Implemented support for CDPATH for ShellCommand ([#1433](https://github.com/pry/pry/issues/1433), [#1434](https://github.com/pry/pry/issues/1434))
|
39
|
+
* `Pry::CLI.parse_options` does not start Pry anymore ([#1393](https://github.com/pry/pry/pull/1393))
|
40
|
+
* The gem uses CPU-less platforms for Windows now ([#1410](https://github.com/pry/pry/pull/1410))
|
41
|
+
* Add `Pry::Config::Memoization` to make it easier to implement your own `Pry::Config::Default` class.([#1503](https://github.com/pry/pry/pull/1503/))
|
42
|
+
* Lazy load the config defaults for `Pry.config.history` and `Pry.config.gist`.
|
9
43
|
|
10
44
|
### 0.10.1
|
11
45
|
|
@@ -376,7 +410,7 @@
|
|
376
410
|
* Fewer internal methods polluting output
|
377
411
|
|
378
412
|
### 0.9.8.4 (2012/6/3)
|
379
|
-
* ~/.pry_history
|
413
|
+
* ~/.pry_history wasn't being created (if it did not exist)! FIXED
|
380
414
|
* `hist --save` saved colors! FIXED
|
381
415
|
* added Pry#add_sticky_local API for adding sticky locals to individual pry instances
|
382
416
|
|
@@ -384,7 +418,7 @@
|
|
384
418
|
* various tweaks to improve rbx support
|
385
419
|
* commands now support optional block arguments
|
386
420
|
* much improved help command
|
387
|
-
* updated method_source
|
421
|
+
* updated method_source dependency
|
388
422
|
* added wtf command
|
389
423
|
* jruby should now work in windows (though without color)
|
390
424
|
|
@@ -412,7 +446,7 @@ MAJOR NEW FEATURES
|
|
412
446
|
- added gist command (removed gist-method, new gist command is more general)
|
413
447
|
|
414
448
|
complete CHANGELOG:
|
415
|
-
* CommandError's no longer cause the current input to be
|
449
|
+
* CommandError's no longer cause the current input to be discarded
|
416
450
|
* Better syntax highlighting for rbx code code
|
417
451
|
* added cat --in to show pry input history
|
418
452
|
* prefixed temporary file names with 'pry'
|
@@ -425,7 +459,7 @@ complete CHANGELOG:
|
|
425
459
|
* added CommandSet#{before_command,after_command} for enhancing builtin commands
|
426
460
|
* added checking for namespace collisions with pry commands, set Pry.config.collision_warning
|
427
461
|
* work around namespace collisions by ensuring lines starting with a space are executed as
|
428
|
-
* ruby.work around namespace collisions by
|
462
|
+
* ruby.work around namespace collisions by pressuring lines starting with a space are executed as ruby
|
429
463
|
* added handlers for Ctrl+C (SIGINT) on jruby, these are now caught as in other ruby versions
|
430
464
|
* removed dependency on ruby_parser
|
431
465
|
* prevented colours leaking across the pry prompt
|
@@ -445,7 +479,7 @@ complete CHANGELOG:
|
|
445
479
|
|
446
480
|
### 0.9.7.4 (2011/11/5)
|
447
481
|
* ls -M now works in modules (bugfix)
|
448
|
-
* added exception
|
482
|
+
* added exception message for bad cd object/path
|
449
483
|
* no longer die when encounter exceptions in .pryrc
|
450
484
|
* baked in CoolLine support
|
451
485
|
* Pry.config.input in .pryrc now respected
|
@@ -462,7 +496,7 @@ complete CHANGELOG:
|
|
462
496
|
* changed ^D so it no longer resets indent level automatically
|
463
497
|
|
464
498
|
### 0.9.7.1 (2011/10/26)
|
465
|
-
* fixed gem
|
499
|
+
* fixed gem dependency issues
|
466
500
|
|
467
501
|
### 0.9.7 (2011/10/25)
|
468
502
|
|
@@ -503,7 +537,7 @@ complete CHANGELOG:
|
|
503
537
|
* play -m --open uses show-input to show play'd code
|
504
538
|
* added "unindent" helper to make adding help to commands easier
|
505
539
|
* local ./.pryrc now loaded after ~/.pryrc if it exists
|
506
|
-
* cat --ex N and edit --ex N now can navigate through backtrace, where cat --ex (with no args) moves
|
540
|
+
* cat --ex N and edit --ex N now can navigate through backtrace, where cat --ex (with no args) moves through successive levels of the backtrace automatically with state stored on the exception object itself
|
507
541
|
* new option Pry.config.exception_window_size determines window size for cat --ex
|
508
542
|
* input_stack now implemented - pushing objects onto a pry instance's input_stack causes the instance to read from those objects in turn as it encounters EOF on the previous object. On finishing the input_stack the input object for the pry instance is set back to Pry.config.input, if this fails, pry breaks out of the REPL (throw(:breakout)) with an error message
|
509
543
|
* Pry.config.system() defines how pry runs system commands
|
@@ -536,10 +570,10 @@ complete CHANGELOG:
|
|
536
570
|
* fixed bug #200 ( https://github.com/pry/pry/issues/200 )- string interpolation bug (thanks to ryanf)
|
537
571
|
* show-doc and stat now display method visibility (update WIKI)
|
538
572
|
* got rid of warnings caused by stricter ruby 1.9.3 rules
|
539
|
-
* remove interpolation of command names and fix interpolation error
|
573
|
+
* remove interpolation of command names and fix interpolation error message (update WIKI) (thanks ryanf!)
|
540
574
|
* 'nested sessions' now use binding stacks (so each instance manages its own collection of bindings without spawning other instances)
|
541
575
|
* 'cd ..' just pops a binding off the binding_stack with special behaviour when only one binding in stack - it breaks out of the repl loop
|
542
|
-
* added switch-to command (like jump-to but
|
576
|
+
* added switch-to command (like jump-to but doesn't unwind the stack)
|
543
577
|
* show-method and show-doc now accept multiple method names
|
544
578
|
* control_d hook added (Pry.config.control_d_handler)
|
545
579
|
* behaviour of ^d is now to break out of current expr if in multi-line expr, or break out of current context if nested, or break out of pry repl loop if at top-level
|
@@ -633,7 +667,7 @@ complete CHANGELOG:
|
|
633
667
|
* -I mode for pry commandline
|
634
668
|
* --color mode for pry commandline
|
635
669
|
* clean up requires (put them all in one place)
|
636
|
-
* simple-prompt command and toggle-color
|
670
|
+
* simple-prompt command and toggle-color command.
|
637
671
|
|
638
672
|
### 0.6.3 (2011/2/28)
|
639
673
|
* Using MethodSource 0.3.4 so 1.8 show-method support provided
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,27 +1,26 @@
|
|
1
1
|
[](https://travis-ci.org/pry/pry)
|
2
2
|
[](https://codeclimate.com/github/pry/pry)
|
3
|
-
[](http://inch-ci.org/github/pry/pry)
|
3
|
+
[](http://inch-ci.org/github/pry/pry)
|
4
|
+
<br><br>
|
5
|
+

|
4
6
|
|
5
|
-
<
|
6
|
-

|
7
|
+
© John Mair ([banisterfiend](https://twitter.com/banisterfiend)) 2016<br>
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
**Please** [DONATE](http://www.pledgie.com/campaigns/15899) to the Pry project - Pry was a **huge** amount of work and every donation received is encouraging and supports Pry's continued development!
|
9
|
+
**Please** [DONATE](http://pledgie.com/campaigns/15899) to the Pry project - Pry was a **huge** amount of work and every donation received is encouraging and supports Pry's continued development!
|
11
10
|
|
12
11
|
**Sponsors**
|
13
12
|
|
14
|
-
[
|
15
|
-
[Atomic Object](
|
16
|
-
[Hashrocket](
|
17
|
-
[Intridea](http://intridea.com
|
18
|
-
[Gaslight](
|
13
|
+
[Launch School](https://launchschool.com)<br/>
|
14
|
+
[Atomic Object](https://atomicobject.com/)<br/>
|
15
|
+
[Hashrocket](https://hashrocket.com/)<br/>
|
16
|
+
[Intridea](http://www.intridea.com)<br/>
|
17
|
+
[Gaslight](https://teamgaslight.com)<br/>
|
19
18
|
|
20
19
|
**Other Resources**
|
21
20
|
|
22
|
-
[Skip to the website (recommended)](http://
|
21
|
+
[Skip to the website (recommended)](http://pryrepl.org/) <br />
|
23
22
|
[Skip to the wiki](https://github.com/pry/pry/wiki)
|
24
|
-
|
23
|
+
|
25
24
|
|
26
25
|
Pry is a powerful alternative to the standard IRB shell for Ruby. It is
|
27
26
|
written from scratch to provide a number of advanced features,
|
@@ -44,7 +43,7 @@ including:
|
|
44
43
|
|
45
44
|
Pry also aims to be more than an IRB replacement; it is an
|
46
45
|
attempt to bring REPL driven programming to the Ruby language. It is
|
47
|
-
currently not as powerful as tools like [SLIME](
|
46
|
+
currently not as powerful as tools like [SLIME](https://en.wikipedia.org/wiki/SLIME) for lisp, but that is the
|
48
47
|
general direction Pry is heading.
|
49
48
|
|
50
49
|
Pry is also fairly flexible and allows significant user
|
@@ -64,8 +63,8 @@ methods. The additional docs are accessed through the `show-doc` and
|
|
64
63
|
|
65
64
|
* Install the [gem](https://rubygems.org/gems/pry): `gem install pry`
|
66
65
|
* Browse the comprehensive [documentation at the official Pry wiki](https://github.com/pry/pry/wiki)
|
67
|
-
* Read the [YARD API documentation](http://
|
68
|
-
* See the [source code](
|
66
|
+
* Read the [YARD API documentation](http://www.rubydoc.info/github/pry/pry/)
|
67
|
+
* See the [source code](https://github.com/pry/pry)
|
69
68
|
|
70
69
|
### Commands
|
71
70
|
|
@@ -137,20 +136,22 @@ implementing developer consoles and applying hot patches.
|
|
137
136
|
|
138
137
|
code:
|
139
138
|
|
140
|
-
|
141
|
-
|
139
|
+
```ruby
|
140
|
+
# test.rb
|
141
|
+
require 'pry'
|
142
142
|
|
143
|
-
|
144
|
-
|
145
|
-
|
143
|
+
class A
|
144
|
+
def hello() puts "hello world!" end
|
145
|
+
end
|
146
146
|
|
147
|
-
|
147
|
+
a = A.new
|
148
148
|
|
149
|
-
|
150
|
-
|
149
|
+
# start a REPL session
|
150
|
+
binding.pry
|
151
151
|
|
152
|
-
|
153
|
-
|
152
|
+
# program resumes here (after pry session)
|
153
|
+
puts "program resumes here."
|
154
|
+
```
|
154
155
|
|
155
156
|
Pry session:
|
156
157
|
|
@@ -314,10 +315,10 @@ We can also use `ri` in the normal way:
|
|
314
315
|
|
315
316
|
### Gist integration
|
316
317
|
|
317
|
-
If the `gist` gem is installed then method source or documentation can be gisted to
|
318
|
+
If the `gist` gem is installed then method source or documentation can be gisted to GitHub with the
|
318
319
|
`gist` command. The `gist` command is capable of gisting [almost any REPL content](https://gist.github.com/cae143e4533416529726), including methods, documentation,
|
319
320
|
input expressions, command source, and so on. In the example below we will gist the C source
|
320
|
-
code for the `Symbol#to_proc` method to
|
321
|
+
code for the `Symbol#to_proc` method to GitHub:
|
321
322
|
|
322
323
|
pry(main)> gist -m Symbol#to_proc
|
323
324
|
Gist created at https://gist.github.com/5332c38afc46d902ce46 and added to clipboard.
|
@@ -351,7 +352,7 @@ Many other commands are available in Pry; to see the full list type
|
|
351
352
|
with basic instructions for use; some commands have a more extensive
|
352
353
|
help that can be accessed via typing `command_name --help`. A command
|
353
354
|
will typically say in its description if the `--help` option is
|
354
|
-
|
355
|
+
available.
|
355
356
|
|
356
357
|
### Use Pry as your Rails Console
|
357
358
|
|
@@ -397,10 +398,10 @@ between commands and running commands in background
|
|
397
398
|
|
398
399
|
### Contact
|
399
400
|
|
400
|
-
Problems or questions?
|
401
|
+
Problems or questions? File an issue at [GitHub](https://github.com/pry/pry/issues).
|
401
402
|
|
402
403
|
### Contributors
|
403
404
|
|
404
|
-
Pry is primarily the work of [John Mair (banisterfiend)](
|
405
|
+
Pry is primarily the work of [John Mair (banisterfiend)](https://github.com/banister), for full list
|
405
406
|
of contributors see the
|
406
407
|
[CONTRIBUTORS](https://github.com/pry/pry/blob/master/CONTRIBUTORS) file.
|
data/bin/pry
CHANGED
@@ -5,12 +5,8 @@
|
|
5
5
|
|
6
6
|
$0 = 'pry'
|
7
7
|
|
8
|
-
|
9
|
-
require 'pry'
|
10
|
-
rescue LoadError
|
11
|
-
require 'rubygems'
|
12
|
-
require 'pry'
|
13
|
-
end
|
8
|
+
require 'pry'
|
14
9
|
|
15
10
|
# Process command line options and run Pry
|
16
|
-
Pry::CLI.parse_options
|
11
|
+
opts = Pry::CLI.parse_options
|
12
|
+
Pry::CLI.start(opts)
|
data/lib/pry.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
|
-
# (C) John Mair (banisterfiend)
|
1
|
+
# (C) John Mair (banisterfiend) 2016
|
2
2
|
# MIT License
|
3
3
|
#
|
4
4
|
require 'pp'
|
5
|
-
|
5
|
+
require 'pry/forwardable'
|
6
6
|
require 'pry/input_lock'
|
7
7
|
require 'pry/exceptions'
|
8
8
|
require 'pry/helpers/base_helpers'
|
9
9
|
require 'pry/hooks'
|
10
|
-
require 'forwardable'
|
11
10
|
|
12
11
|
class Pry
|
13
12
|
# The default hooks - display messages when beginning and ending Pry sessions.
|
@@ -124,8 +123,9 @@ end
|
|
124
123
|
require 'method_source'
|
125
124
|
require 'shellwords'
|
126
125
|
require 'stringio'
|
126
|
+
require 'strscan'
|
127
127
|
require 'coderay'
|
128
|
-
require 'slop'
|
128
|
+
require 'pry/slop'
|
129
129
|
require 'rbconfig'
|
130
130
|
require 'tempfile'
|
131
131
|
require 'pathname'
|
data/lib/pry/cli.rb
CHANGED
@@ -19,7 +19,7 @@ class Pry
|
|
19
19
|
# as CLI options.
|
20
20
|
attr_accessor :input_args
|
21
21
|
|
22
|
-
# Add another set of CLI options (a Slop block)
|
22
|
+
# Add another set of CLI options (a Pry::Slop block)
|
23
23
|
def add_options(&block)
|
24
24
|
if options
|
25
25
|
old_options = options
|
@@ -62,28 +62,58 @@ class Pry
|
|
62
62
|
raise NoOptionsError, "No command line options defined! Use Pry::CLI.add_options to add command line options."
|
63
63
|
end
|
64
64
|
|
65
|
+
# Load config files etc first, ensuring that cli options will take precedence.
|
66
|
+
Pry.initial_session_setup
|
67
|
+
|
65
68
|
self.input_args = args
|
66
69
|
|
67
70
|
begin
|
68
|
-
opts = Slop.parse!(
|
71
|
+
opts = Pry::Slop.parse!(
|
69
72
|
args,
|
70
73
|
:help => true,
|
71
74
|
:multiple_switches => false,
|
72
75
|
:strict => true,
|
73
76
|
&options
|
74
77
|
)
|
75
|
-
rescue Slop::InvalidOptionError
|
78
|
+
rescue Pry::Slop::InvalidOptionError
|
76
79
|
# Display help message on unknown switches and exit.
|
77
|
-
puts Slop.new(&options)
|
80
|
+
puts Pry::Slop.new(&options)
|
78
81
|
exit
|
79
82
|
end
|
80
83
|
|
84
|
+
Pry.final_session_setup
|
85
|
+
|
81
86
|
# Option processors are optional.
|
82
87
|
if option_processors
|
83
88
|
option_processors.each { |processor| processor.call(opts) }
|
84
89
|
end
|
85
90
|
|
86
|
-
|
91
|
+
opts
|
92
|
+
end
|
93
|
+
|
94
|
+
def start(opts)
|
95
|
+
exit if opts.help?
|
96
|
+
|
97
|
+
# invoked via cli
|
98
|
+
Pry.cli = true
|
99
|
+
|
100
|
+
# create the actual context
|
101
|
+
if opts[:context]
|
102
|
+
Pry.initial_session_setup
|
103
|
+
context = Pry.binding_for(eval(opts[:context]))
|
104
|
+
Pry.final_session_setup
|
105
|
+
else
|
106
|
+
context = Pry.toplevel_binding
|
107
|
+
end
|
108
|
+
|
109
|
+
if Pry::CLI.input_args.any? && Pry::CLI.input_args != ["pry"]
|
110
|
+
full_name = File.expand_path(Pry::CLI.input_args.first)
|
111
|
+
Pry.load_file_through_repl(full_name)
|
112
|
+
exit
|
113
|
+
end
|
114
|
+
|
115
|
+
# Start the session (running any code passed with -e, if there is any)
|
116
|
+
Pry.start(context, :input => StringIO.new(Pry.config.exec_string))
|
87
117
|
end
|
88
118
|
|
89
119
|
end
|
@@ -93,11 +123,8 @@ class Pry
|
|
93
123
|
end
|
94
124
|
|
95
125
|
|
96
|
-
# String that is built to be executed on start (created by -e and -exec switches)
|
97
|
-
exec_string = ""
|
98
|
-
|
99
126
|
# Bring in options defined by plugins
|
100
|
-
Slop.new do
|
127
|
+
Pry::Slop.new do
|
101
128
|
on "no-plugins" do
|
102
129
|
Pry.config.should_load_plugins = false
|
103
130
|
end
|
@@ -112,11 +139,12 @@ Pry::CLI.add_options do
|
|
112
139
|
banner %{Usage: pry [OPTIONS]
|
113
140
|
Start a Pry session.
|
114
141
|
See http://pryrepl.org/ for more information.
|
115
|
-
Copyright (c)
|
142
|
+
Copyright (c) 2016 John Mair (banisterfiend)
|
116
143
|
--
|
117
144
|
}
|
118
145
|
on :e, :exec=, "A line of code to execute in context before the session starts" do |input|
|
119
|
-
exec_string
|
146
|
+
Pry.config.exec_string += "\n" if Pry.config.exec_string.length > 0
|
147
|
+
Pry.config.exec_string += input
|
120
148
|
end
|
121
149
|
|
122
150
|
on "no-pager", "Disable pager for long output" do
|
@@ -194,27 +222,4 @@ Copyright (c) 2013 John Mair (banisterfiend)
|
|
194
222
|
"Start the session in the specified context. Equivalent to `context.pry` in a session.",
|
195
223
|
:default => "Pry.toplevel_binding"
|
196
224
|
)
|
197
|
-
end.add_option_processor do |opts|
|
198
|
-
|
199
|
-
exit if opts.help?
|
200
|
-
|
201
|
-
# invoked via cli
|
202
|
-
Pry.cli = true
|
203
|
-
|
204
|
-
# create the actual context
|
205
|
-
if opts[:context]
|
206
|
-
Pry.initial_session_setup
|
207
|
-
context = Pry.binding_for(eval(opts[:context]))
|
208
|
-
else
|
209
|
-
context = Pry.toplevel_binding
|
210
|
-
end
|
211
|
-
|
212
|
-
if Pry::CLI.input_args.any? && Pry::CLI.input_args != ["pry"]
|
213
|
-
full_name = File.expand_path(Pry::CLI.input_args.first)
|
214
|
-
Pry.load_file_through_repl(full_name)
|
215
|
-
exit
|
216
|
-
end
|
217
|
-
|
218
|
-
# Start the session (running any code passed with -e, if there is any)
|
219
|
-
Pry.start(context, :input => StringIO.new(exec_string))
|
220
225
|
end
|