Skip to content

Commit 497153d

Browse files
authored
Merge pull request #50 from pry/feat-stack-command
Rename command to 'stack'
2 parents 2a280ba + 3c3346f commit 497153d

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Rename 'show-stack' to 'stack' (#50, #8)
2+
13
## v0.5.1 (21 May 2020)
24
* Fix exception in started hook
35

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Unlike `ruby-debug`, pry-stack_explorer incurs no runtime cost and
1717
enables navigation right up the call-stack to the birth of the
1818
program.
1919

20-
The `up`, `down`, `frame` and `show-stack` commands are provided. See
20+
The `up`, `down`, `frame` and `stack` commands are provided. See
2121
Pry's in-session help for more information on any of these commands.
2222

2323
## Usage
@@ -26,7 +26,7 @@ Provides commands available in Pry sessions.
2626
Commands:
2727
* `up`/`down` - Move up or down the call stack
2828
* `frame [n]` - Go to frame *n*
29-
* `show-stack` - Show call stack
29+
* `stack` - Show call stack
3030

3131

3232
## Install

lib/pry-stack_explorer/commands.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,15 @@ def process
231231
end
232232
end
233233

234-
create_command "show-stack", "Show all frames" do
234+
create_command "stack", "Show all frames" do
235235
include FrameHelpers
236236

237237
banner <<-BANNER
238-
Usage: show-stack [OPTIONS]
238+
Usage: stack [OPTIONS]
239239
Show all accessible stack frames.
240-
e.g: show-stack -v
240+
e.g: stack -v
241+
242+
alias: show-stack
241243
BANNER
242244

243245
def options(opt)
@@ -309,5 +311,8 @@ def process
309311
end
310312

311313
end
314+
315+
alias_command "show-stack", "stack"
316+
312317
end
313318
end

test/commands_test.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ def bang
4949
Pry.config.hooks.delete_hook(:after_session, :delete_frame_manager)
5050
end
5151

52+
describe "stack" do
53+
it "outputs the call stack" do
54+
output = issue_pry_commands("stack"){ bingbong.bing }
55+
56+
expect(output).to match(/bang.*?bong.*?bing/m)
57+
end
58+
59+
it "supports 'show-stack' as an alias" do
60+
output = issue_pry_commands("show-stack"){ bingbong.bing }
61+
62+
expect(output).to match(/bang.*?bong.*?bing/m)
63+
end
64+
end
65+
5266
describe "up" do
5367
it 'should move up the call stack one frame at a time' do
5468
redirect_pry_io(InputTester.new("@methods << __method__",

test/stack_explorer_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def o.==(other)
9999

100100
describe ":call_stack option" do
101101
it 'should invoke a session with the call stack set' do
102-
redirect_pry_io(StringIO.new("show-stack\nexit\n"), out=StringIO.new) do
102+
redirect_pry_io(StringIO.new("stack\nexit\n"), out=StringIO.new) do
103103
@o.bing
104104
end
105105

@@ -112,7 +112,7 @@ def o.bing() bong end
112112
def o.bong() bang end
113113
def o.bang() Pry.start(binding, :call_stack => false) end
114114

115-
redirect_pry_io(StringIO.new("show-stack\nexit\n"), out=StringIO.new) do
115+
redirect_pry_io(StringIO.new("stack\nexit\n"), out=StringIO.new) do
116116
o.bing
117117
end
118118

@@ -125,7 +125,7 @@ def o.alpha() binding end
125125
def o.beta() binding end
126126
def o.gamma() binding end
127127

128-
redirect_pry_io(StringIO.new("show-stack\nexit\n"), out=StringIO.new) do
128+
redirect_pry_io(StringIO.new("stack\nexit\n"), out=StringIO.new) do
129129
Pry.start(binding, :call_stack => [o.beta, o.gamma, o.alpha])
130130
end
131131

0 commit comments

Comments
 (0)