From 41a9c8ec055bfa0090154a9dd85d4a35a0dce3d0 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Wed, 10 Nov 2021 16:44:29 +0100 Subject: [PATCH] "implement" 'history', 'version' & 'uname' at repl level --- repl.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/repl.rb b/repl.rb index f9b8636..6cb0938 100644 --- a/repl.rb +++ b/repl.rb @@ -19,12 +19,7 @@ module Rpn def run Readline.completion_proc = proc do |s| - directory_list = Dir.glob("#{s}*") - if directory_list.positive? - directory_list - else - Readline::HISTORY.grep(/^#{Regexp.escape(s)}/) - end + Readline::HISTORY.grep(/^#{Regexp.escape(s)}/) end Readline.completion_append_character = ' ' @@ -32,6 +27,10 @@ module Rpn input = Readline.readline( ' ', true ) 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 Readline::HISTORY.pop if input.empty?