diff --git a/CHANGELOG b/CHANGELOG index 03f4afa..58891ae 100755 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Rename 'show-stack' to 'stack' (#50, #8) + ## v0.5.1 (21 May 2020) * Fix exception in started hook diff --git a/README.md b/README.md index 6e38823..ccdb1e0 100755 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Unlike `ruby-debug`, pry-stack_explorer incurs no runtime cost and enables navigation right up the call-stack to the birth of the program. -The `up`, `down`, `frame` and `show-stack` commands are provided. See +The `up`, `down`, `frame` and `stack` commands are provided. See Pry's in-session help for more information on any of these commands. ## Usage @@ -26,7 +26,7 @@ Provides commands available in Pry sessions. Commands: * `up`/`down` - Move up or down the call stack * `frame [n]` - Go to frame *n* -* `show-stack` - Show call stack +* `stack` - Show call stack ## Install diff --git a/lib/pry-stack_explorer/commands.rb b/lib/pry-stack_explorer/commands.rb index 90a8b2e..a5cec32 100644 --- a/lib/pry-stack_explorer/commands.rb +++ b/lib/pry-stack_explorer/commands.rb @@ -231,13 +231,15 @@ def process end end - create_command "show-stack", "Show all frames" do + create_command "stack", "Show all frames" do include FrameHelpers banner <<-BANNER - Usage: show-stack [OPTIONS] + Usage: stack [OPTIONS] Show all accessible stack frames. - e.g: show-stack -v + e.g: stack -v + + alias: show-stack BANNER def options(opt) @@ -309,5 +311,8 @@ def process end end + + alias_command "show-stack", "stack" + end end diff --git a/test/commands_test.rb b/test/commands_test.rb index eb8a429..6c06efe 100644 --- a/test/commands_test.rb +++ b/test/commands_test.rb @@ -49,6 +49,20 @@ def bang Pry.config.hooks.delete_hook(:after_session, :delete_frame_manager) end + describe "stack" do + it "outputs the call stack" do + output = issue_pry_commands("stack"){ bingbong.bing } + + expect(output).to match(/bang.*?bong.*?bing/m) + end + + it "supports 'show-stack' as an alias" do + output = issue_pry_commands("show-stack"){ bingbong.bing } + + expect(output).to match(/bang.*?bong.*?bing/m) + end + end + describe "up" do it 'should move up the call stack one frame at a time' do redirect_pry_io(InputTester.new("@methods << __method__", diff --git a/test/stack_explorer_test.rb b/test/stack_explorer_test.rb index 3026e8f..0d321b0 100644 --- a/test/stack_explorer_test.rb +++ b/test/stack_explorer_test.rb @@ -99,7 +99,7 @@ def o.==(other) describe ":call_stack option" do it 'should invoke a session with the call stack set' do - redirect_pry_io(StringIO.new("show-stack\nexit\n"), out=StringIO.new) do + redirect_pry_io(StringIO.new("stack\nexit\n"), out=StringIO.new) do @o.bing end @@ -112,7 +112,7 @@ def o.bing() bong end def o.bong() bang end def o.bang() Pry.start(binding, :call_stack => false) end - redirect_pry_io(StringIO.new("show-stack\nexit\n"), out=StringIO.new) do + redirect_pry_io(StringIO.new("stack\nexit\n"), out=StringIO.new) do o.bing end @@ -125,7 +125,7 @@ def o.alpha() binding end def o.beta() binding end def o.gamma() binding end - redirect_pry_io(StringIO.new("show-stack\nexit\n"), out=StringIO.new) do + redirect_pry_io(StringIO.new("stack\nexit\n"), out=StringIO.new) do Pry.start(binding, :call_stack => [o.beta, o.gamma, o.alpha]) end