class DbSucker::Application::Window::Keypad
Constants
- HELP_INFO
Attributes
keyloop[R]
prompt[R]
window[R]
Public Class Methods
new(window)
click to toggle source
# File lib/db_sucker/application/window/keypad.rb, line 8 def initialize window @window = window @prompt = Prompt.new(@window, self) @monitor = Monitor.new end
Public Instance Methods
cancel_workers(args)
click to toggle source
# File lib/db_sucker/application/window/keypad.rb, line 149 def cancel_workers args if args[0].is_a?(String) window.flashbang _detect_worker(args.join(" ")) do |wrk| wrk.cancel! "canceled by user" end else prompt!("Usage: :c(cancel) <table_name|--all>", color: :yellow) end end
dump_core()
click to toggle source
# File lib/db_sucker/application/window/keypad.rb, line 188 def dump_core app.dump_core end
eval_prompt()
click to toggle source
# File lib/db_sucker/application/window/keypad.rb, line 83 def eval_prompt prompt!("eval> ") {|evil| _eval(evil) } end
handle_input(ch)
click to toggle source
# File lib/db_sucker/application/window/keypad.rb, line 41 def handle_input ch sync do if @prompt.interactive? @prompt.handle_input(ch) else case ch when ":" then main_prompt when "^" then eval_prompt # (@development) when "L" then show_log # (@development) when "T" then dump_core # (@development) when "P" then kill_ssh_poll when "?" then show_help when "q" then quit_dialog when "Q" then $core_runtime_exiting = 1 when "S" then signal_threads end end end end
kill_app()
click to toggle source
# File lib/db_sucker/application/window/keypad.rb, line 184 def kill_app exit! end
kill_ssh_poll()
click to toggle source
# File lib/db_sucker/application/window/keypad.rb, line 160 def kill_ssh_poll if sklaventreiber.workers.select{|w| !w.done? || w.sshing }.any? app.print("\a") prompt!("Error: cannot kill SSH poll whilst in use", color: :red) else window.flashbang sklaventreiber.poll.try(:kill) end end
kill_workers()
click to toggle source
# File lib/db_sucker/application/window/keypad.rb, line 170 def kill_workers window.flashbang Thread.list.each do |thr| thr.raise(Interrupt) if thr[:managed_worker] end end
main_prompt()
click to toggle source
# File lib/db_sucker/application/window/keypad.rb, line 61 def main_prompt prompt!(":") do |raw| break if raw.blank? args = raw.split(" ") cmd = args.shift case cmd when "?", "h", "help" then show_help when "c", "cancel" then cancel_workers(args) when "q", "quit" then quit_dialog when "q!", "quit!" then $core_runtime_exiting = 1 when "kill" then kill_workers when "kill!" then kill_app when "dump" then dump_core when "eval" then args.any? ? _eval(args.join(" ")) : eval_prompt when "p", "pause" then pause_workers(args) when "r", "resume" then resume_workers(args) when "signal-threads" then signal_threads else app.print("\a") end end end
pause_workers(args)
click to toggle source
# File lib/db_sucker/application/window/keypad.rb, line 131 def pause_workers args if args[0].is_a?(String) window.flashbang _detect_worker(args.join(" "), &:pause) else prompt!("Usage: :p(ause) <table_name|--all>", color: :yellow) end end
quit_dialog()
click to toggle source
# File lib/db_sucker/application/window/keypad.rb, line 87 def quit_dialog q = "Do you want to abort all operations and quit?" p = Proc.new do blue q gray " [y/q/t/1 n/f/0] " end prompt!(q, prompt: p, return_on_buffer: true, capture_enter: false, has_cursor: false ) do |response| if response == "q" || @window.strbool(response) == true $core_runtime_exiting = 1 end end end
resume_workers(args)
click to toggle source
# File lib/db_sucker/application/window/keypad.rb, line 140 def resume_workers args if args[0].is_a?(String) window.flashbang _detect_worker(args.join(" "), &:unpause) else prompt!("Usage: :r(esume) <table_name|--all>", color: :yellow) end end
show_help()
click to toggle source
# File lib/db_sucker/application/window/keypad.rb, line 105 def show_help view_was = window.change_view(:help) prompt!("[press any key to return]", return_on_buffer: true, capture_enter: false, has_cursor: false, capture_escape: false, cursor_visible: false ) do |response| window.change_view(view_was) end end
show_log()
click to toggle source
# File lib/db_sucker/application/window/keypad.rb, line 118 def show_log view_was = window.change_view(:log) prompt!("[press any key to return]", return_on_buffer: true, capture_enter: false, has_cursor: false, capture_escape: false, cursor_visible: false ) do |response| window.change_view(view_was) end end
signal_threads()
click to toggle source
# File lib/db_sucker/application/window/keypad.rb, line 177 def signal_threads window.flashbang Thread.list.each do |thr| thr.signal if thr.respond_to?(:signal) end end