Skip to content

Commit 939052c

Browse files
committed
Enter X to exit Pry.
1 parent 2deffc7 commit 939052c

5 files changed

Lines changed: 22 additions & 3 deletions

File tree

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
lit-cli (0.8.0)
4+
lit-cli (0.8.1)
55
pastel
66
pry
77

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Step through the code. The terminal will stop at each `lit()` message, then prom
4848
lit @step ruby script.rb
4949
```
5050

51+
When in a Pry session, enter `x` to exit Pry or `!!!` to exit the program.
52+
5153
**Note:** Only files required via `require_relative` are currently supported for Pry session.
5254
**Note:** Pry is not available to `lit()` messages in the *first* file to `require 'lit_cli'`, so require Lit in your application's entry point / main file if you need this feature.
5355

lib/lit_cli.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ def self.step(indent)
8585
puts "#{indent}🔥 Press ENTER to step or P to Pry:"
8686
input = gets.chomp
8787
binding while input == nil
88-
@@is_prying = true if input.downcase == "p"
88+
if input.downcase == "p"
89+
puts @@pastel.dim("Enter X to exit Pry or !!! to exit program.")
90+
@@is_prying = true
91+
end
8992
end
9093
end
9194

lib/lit_pry.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,17 @@ def self.add_lit_binding(line)
107107
end
108108
end
109109
end
110+
111+
##
112+
# Add custom Pry command for a nicer exiting experience.
113+
# @see https://github.com/pry/pry/wiki/Custom-commands
114+
##
115+
command_description = "Alias for `exit`"
116+
117+
Pry::Commands.block_command "x", command_description do
118+
run "exit"
119+
end
120+
121+
Pry::Commands.block_command "X", command_description do
122+
run "exit"
123+
end

lit-cli.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |spec|
22

33
spec.name = 'lit-cli'
4-
spec.version = '0.8.0'
4+
spec.version = '0.8.1'
55
spec.date = '2021-02-14'
66
spec.authors = ["Maedi Prichard"]
77
spec.email = 'maediprichard@gmail.com'

0 commit comments

Comments
 (0)