1
0
Fork 0
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:
yui-knk 2013-12-17 23:24:34 +09:00
parent 54a7f9a139
commit ca047ba99d
2 changed files with 16 additions and 0 deletions

View file

@ -242,6 +242,7 @@ class Pry
# @example # @example
# run "amend-line", "5", 'puts "hello world"' # run "amend-line", "5", 'puts "hello world"'
def run(command_string, *args) def run(command_string, *args)
command_string = Pry.config.command_prefix.to_s + command_string
complete_string = "#{command_string} #{args.join(" ")}".rstrip complete_string = "#{command_string} #{args.join(" ")}".rstrip
command_set.process_line(complete_string, context) command_set.process_line(complete_string, context)
end end

View file

@ -183,6 +183,21 @@ describe Pry::CommandSet do
run.should == true run.should == true
end 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 it 'should inherit options from original command' do
run = false run = false
@set.command('foo', 'stuff', :shellwords => true, :interpolate => false) { run = true } @set.command('foo', 'stuff', :shellwords => true, :interpolate => false) { run = true }