mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
* got run command working by passing in extra 'target' argument. Got
command string interpolation working, so .cd #{my_dir} now works.
This commit is contained in:
parent
d111b19f82
commit
ad0e3b9d9f
3 changed files with 16 additions and 7 deletions
2
TODO
2
TODO
|
@ -3,6 +3,8 @@ FUTURE
|
|||
* allows pipes (|) for commands
|
||||
|
||||
0.8.0
|
||||
* allow #{} interpolation of all commands
|
||||
* update documentation! new commands and features and change in behaviour of `run`
|
||||
* add ; at end of line to suppress return value output
|
||||
* Remove message spam (before/after hooks)
|
||||
* stop commands returning a value
|
||||
|
|
|
@ -83,7 +83,7 @@ class Pry
|
|||
command_processor = CommandProcessor.new(target.eval('_pry_'))
|
||||
|
||||
if command_processor.system_command?(name)
|
||||
command_processor.execute_system_command("#{name} #{args.join}")
|
||||
command_processor.execute_system_command("#{name} #{args.join}", target)
|
||||
else
|
||||
action = opts[:commands][name][:action]
|
||||
instance_exec(*args, &action)
|
||||
|
|
|
@ -26,10 +26,16 @@ class Pry
|
|||
def pry_command?(val)
|
||||
!!command_matched(val).first
|
||||
end
|
||||
|
||||
def interpolate_string(str, target)
|
||||
dumped_str = str.dump
|
||||
dumped_str.gsub!(/\\\#{/, '#{')
|
||||
target.eval(dumped_str)
|
||||
end
|
||||
|
||||
def execute_system_command(val)
|
||||
def execute_system_command(val, target)
|
||||
SYSTEM_COMMAND_REGEX =~ val
|
||||
cmd = $1
|
||||
cmd = interpolate_string($1, target)
|
||||
|
||||
if cmd =~ /^cd\s+(.+)/i
|
||||
begin
|
||||
|
@ -71,15 +77,16 @@ class Pry
|
|||
def eval_string.clear() replace("") end
|
||||
|
||||
if system_command?(val)
|
||||
execute_system_command(val)
|
||||
execute_system_command(val, target)
|
||||
return
|
||||
end
|
||||
|
||||
# no command was matched, so return to caller
|
||||
return if !pry_command?(val)
|
||||
|
||||
val.replace interpolate_string(val, target)
|
||||
cmd_data, args_string = command_matched(val)
|
||||
|
||||
# no command was matched, so return to caller
|
||||
return if !cmd_data
|
||||
|
||||
args = args_string ? Shellwords.shellwords(args_string) : []
|
||||
action = cmd_data[:action]
|
||||
keep_retval = cmd_data[:keep_retval]
|
||||
|
|
Loading…
Add table
Reference in a new issue