Readline interface: Difference between revisions

(PARI)
(→‎{{header|Ruby}}: Added Ruby)
Line 486:
 
{{omit from|GUISS}}
=={{header|Ruby}}==
This application provides auto-completion for these commands: ''search download open help history quit url prev past''.
<br>Auto-completion is applied by pressing the tab-key.
<br>A history of the commands is navigated by the up- and down-keys. All commands are just echoed, except "quit" which exits.
<br>It uses the Ruby 2.3 method Hash#to_proc.
<lang ruby>require "readline"
require "abbrev"
 
commands = %w[search download open help history quit url prev past]
Readline.completion_proc = commands.abbrev.to_proc
 
while buf = Readline.readline(">", true)
exit if buf.start_with? "quit"
p buf
end</lang>
1,149

edits