"implement" 'history', 'version' & 'uname' at repl level
This commit is contained in:
parent
0f924355ca
commit
41a9c8ec05
1 changed files with 5 additions and 6 deletions
9
repl.rb
9
repl.rb
|
@ -19,19 +19,18 @@ module Rpn
|
||||||
|
|
||||||
def run
|
def run
|
||||||
Readline.completion_proc = proc do |s|
|
Readline.completion_proc = proc do |s|
|
||||||
directory_list = Dir.glob("#{s}*")
|
|
||||||
if directory_list.positive?
|
|
||||||
directory_list
|
|
||||||
else
|
|
||||||
Readline::HISTORY.grep(/^#{Regexp.escape(s)}/)
|
Readline::HISTORY.grep(/^#{Regexp.escape(s)}/)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
Readline.completion_append_character = ' '
|
Readline.completion_append_character = ' '
|
||||||
|
|
||||||
loop do
|
loop do
|
||||||
input = Readline.readline( ' ', true )
|
input = Readline.readline( ' ', true )
|
||||||
break if input.nil? || input == 'quit'
|
break if input.nil? || input == 'quit'
|
||||||
|
|
||||||
|
pp Readline::HISTORY if input == 'history'
|
||||||
|
|
||||||
|
input = '"rpn.rb version 0.0"' if %w[version uname].include?( input )
|
||||||
|
|
||||||
# Remove blank lines from history
|
# Remove blank lines from history
|
||||||
Readline::HISTORY.pop if input.empty?
|
Readline::HISTORY.pop if input.empty?
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue