mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Fix alias command do not work with command_prefix. To fix Pry::Command#run is call command_set.process_line with command_prefix arg, in case Pry.config.command_prefix is set.
This commit is contained in:
parent
54a7f9a139
commit
ca047ba99d
2 changed files with 16 additions and 0 deletions
|
@ -242,6 +242,7 @@ class Pry
|
|||
# @example
|
||||
# run "amend-line", "5", 'puts "hello world"'
|
||||
def run(command_string, *args)
|
||||
command_string = Pry.config.command_prefix.to_s + command_string
|
||||
complete_string = "#{command_string} #{args.join(" ")}".rstrip
|
||||
command_set.process_line(complete_string, context)
|
||||
end
|
||||
|
|
|
@ -183,6 +183,21 @@ describe Pry::CommandSet do
|
|||
run.should == true
|
||||
end
|
||||
|
||||
it "should be able to alias command with command_prefix" do
|
||||
run = false
|
||||
@set.command('owl', 'stuff') { run = true }
|
||||
@set.alias_command 'owlet', 'owl'
|
||||
|
||||
Pry.config.command_prefix = '%'
|
||||
@set.commands['owlet'].match.should == 'owlet'
|
||||
@set.commands['owlet'].description.should == 'Alias for `owl`'
|
||||
|
||||
@set.process_line '%owlet', @ctx
|
||||
run.should == true
|
||||
|
||||
Pry.config.command_prefix = ''
|
||||
end
|
||||
|
||||
it 'should inherit options from original command' do
|
||||
run = false
|
||||
@set.command('foo', 'stuff', :shellwords => true, :interpolate => false) { run = true }
|
||||
|
|
Loading…
Add table
Reference in a new issue