You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pry recognize the multi-line string declaration and increment the nest level. But how can I achieve this behavior with my custom command? Equivalent to the previous example the call with my custom command looks like this one:
echo "custom_command \"foo bar ...
nextline...\" | pry
But this does not work. Only the first line "foo bar is accepted as argument. The second line is interpreted as command.
In my custom command class I tried something like this:
def process
input = args.join(' ')
if !$stdin.tty?
if input =~ /^".*/ && input !~ /^".*"$/
while true
line = $stdin.read
input = "#{input} #{line}"
if line =~ /.*"$/
break
end
end
puts "#{input}"
end
end
end
But this approach does not work, because there's nothing to read from $stdin. The variable line is always empty. Does someone know how I can solve this problem? I want, that the complete argument "foo bar ... nextline ..." is read by my custom command.
Thank you in advance and best regards,
Andi
The text was updated successfully, but these errors were encountered:
atschwarz
changed the title
Multiline argument via $stdin and pipe operator
Multiline argument via $stdin and pipe operator using custom commands
Feb 23, 2016
Hi,
I'm trying to implement a custom command for pry, which accepts a multi-line argument via the pipe operator.
The following works fine:
Pry recognize the multi-line string declaration and increment the nest level. But how can I achieve this behavior with my custom command? Equivalent to the previous example the call with my custom command looks like this one:
But this does not work. Only the first line "foo bar is accepted as argument. The second line is interpreted as command.
In my custom command class I tried something like this:
But this approach does not work, because there's nothing to read from $stdin. The variable line is always empty. Does someone know how I can solve this problem? I want, that the complete argument "foo bar ... nextline ..." is read by my custom command.
Thank you in advance and best regards,
Andi
The text was updated successfully, but these errors were encountered: