From a4d2f7f0cc86b53278c88fc1db31504cfd256af9 Mon Sep 17 00:00:00 2001 From: adrien Date: Fri, 20 Dec 2013 17:38:58 +0100 Subject: [PATCH] add history in interactive mode --- lib/Cli.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Cli.rb b/lib/Cli.rb index 60f1cd1..81ae5de 100644 --- a/lib/Cli.rb +++ b/lib/Cli.rb @@ -6,6 +6,7 @@ require 'rubygems' require 'highline/import' require 'pathname' +require 'readline' require "#{APP_ROOT}/lib/MPW.rb" @@ -230,7 +231,8 @@ class Cli group = nil last_access = Time.now.to_i - while true + while buf = Readline.readline(" ", true) + if @m.timeout_pwd < Time.now.to_i - last_access passwd_confirm = ask("Password GPG: ") {|q| q.echo = false} @@ -244,7 +246,7 @@ class Cli last_access = Time.now.to_i end - command = ask(" ").split(' ') + command = buf.split(' ') case command[0] when 'display', 'show', 'd', 's' @@ -291,6 +293,7 @@ class Cli puts '# exit' puts '# q' when 'quit', 'exit', 'q' + puts 'Goodbye!' break else if !command[0].nil? && !command[0].empty?