From 0b3b71e71415f9e7a234fe97466c61d9641dc7da Mon Sep 17 00:00:00 2001 From: Barrett Ingram Date: Sun, 22 Mar 2020 14:18:13 -0500 Subject: [PATCH 1/2] Display Bang command as "!" instead of regex in help listing --- lib/pry/commands/bang.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pry/commands/bang.rb b/lib/pry/commands/bang.rb index ca42834ed..1879c64eb 100644 --- a/lib/pry/commands/bang.rb +++ b/lib/pry/commands/bang.rb @@ -6,7 +6,7 @@ class Bang < Pry::ClassCommand match(/^\s*!\s*$/) group 'Editing' description 'Clear the input buffer.' - command_options use_prefix: false + command_options use_prefix: false, listing: '!' banner <<-'BANNER' Clear the input buffer. Useful if the parsing process goes wrong and you get From a164846c4dc69386432a19a684ea64c2a9e737b5 Mon Sep 17 00:00:00 2001 From: Barrett Ingram Date: Sun, 22 Mar 2020 14:43:20 -0500 Subject: [PATCH 2/2] Improve help listing for regex aliases This commit improves the appearance of regex aliases in the help index by storing the result of calling #inspect on the regex as the listing. For example, consider the `whereami` alias `/whereami[!?]+/`. Previously this would appear in the help index as `(?-mix:whereami[!?]+)`. This commit fixes this so it appears as `/whereami[!?]+/`. --- lib/pry/command_set.rb | 2 +- spec/command_set_spec.rb | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/pry/command_set.rb b/lib/pry/command_set.rb index 70ec2e532..339e6424b 100644 --- a/lib/pry/command_set.rb +++ b/lib/pry/command_set.rb @@ -193,7 +193,7 @@ def alias_command(match, action, options = {}) options = original_options.merge!( desc: "Alias for `#{action}`", - listing: match + listing: match.is_a?(String) ? match : match.inspect ).merge!(options) # ensure default description is used if desc is nil diff --git a/spec/command_set_spec.rb b/spec/command_set_spec.rb index fc67d1409..c52439991 100644 --- a/spec/command_set_spec.rb +++ b/spec/command_set_spec.rb @@ -185,11 +185,16 @@ expect(new_command.description).to eq('Alias for `test`') end - it "sets aliased command's listing" do + it "sets aliased command's listing for string alias" do new_command = subject.alias_command('new-test', 'test') expect(new_command.options).to include(listing: 'new-test') end + it "sets aliased command's listing for regex alias" do + new_command = subject.alias_command(/test[!?]+/, 'test') + expect(new_command.options[:listing].to_s).to eq('/test[!?]+/') + end + it "sets group for the aliased command automatically" do new_command = subject.alias_command('new-test', 'test') expect(new_command.group).to eq('Aliases')