lib/everyday-cli-utils/ask.rb in everyday-cli-utils-1.8.4 vs lib/everyday-cli-utils/ask.rb in everyday-cli-utils-1.8.5
- old
+ new
@@ -25,9 +25,20 @@
resp = Readline.readline("#{question} ([y]es/[n]o) ", true)
val = resp.downcase == 'yes' || resp.downcase == 'y'
block.call(val) if !options[:only] || options[:only] == (val ? :yes : :no)
end
+ def self.ask_prefill(question, prefill)
+ old_hook = Readline.pre_input_hook
+ Readline.pre_input_hook =-> {
+ Readline.insert_text(prefill)
+ Readline.redisplay
+ }
+ rval = Readline.readline(question, true)
+ Readline.pre_input_hook = old_hook
+ rval
+ end
+
def self.hash_to_options(hash, extra = [])
hash.keys + extra
end
end
end
\ No newline at end of file