Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions doc/echo.rb
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should not be added?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should not be added?

You mean the example (echo)? Or the page?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No action on this (yet).

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'reline'
require 'open-uri'

# Get words for completion.
words_url = 'https://raw.githubusercontent.com/first20hours/google-10000-english/refs/heads/master/google-10000-english-usa-no-swears-long.txt'
words = []
URI.open(words_url) do |file|
while !file.eof?
words.push(file.readline.chomp)
end
end
# Install completion proc.
Reline.completion_proc = proc { |word|
words
}
puts 'Welcome to the Echo program!'
puts ' To exit, type Ctrl-d in empty line.'
# REPL (Read-Evaluate-Print Loop)
while line = Reline.readline(prompt = 'echo> ', history = true)
puts "You typed: '#{line.chomp}'."
end
Loading