Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve appearance of help command listing #2120

Merged
merged 2 commits into from Apr 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/pry/command_set.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/commands/bang.rb
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion spec/command_set_spec.rb
Expand Up @@ -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')
Expand Down