class WorkingSetCli
Public Instance Methods
run()
click to toggle source
# File lib/working_set_cli.rb, line 89 def run parse if params[:help] print help exit else init $supervisor = AppSupervisor.run! sleep 0.5 while $supervisor.alive? # I've need to occupy the main thread otherwise the program exits here. end end
Private Instance Methods
check_for_existing_socket_file()
click to toggle source
# File lib/working_set_cli.rb, line 169 def check_for_existing_socket_file if File.exists?($SOCKET_PATH) puts "File #{$SOCKET_PATH.inspect} exists. Overwrite it? (y/N)" require "io/console" if STDIN.getch =~ /y/i File.delete($SOCKET_PATH) else puts "Ok, exiting program." exit end end end
init()
click to toggle source
# File lib/working_set_cli.rb, line 134 def init init_debug init_socket_file init_live_watch init_ncurses $CONTEXT_LINES = params[:context] end
init_debug()
click to toggle source
# File lib/working_set_cli.rb, line 182 def init_debug if params.key?(:debug) require 'tty-logger' path = params[:debug] || "working_set.log" log_file = File.open(path, "a") log_file.sync = true $logger = TTY::Logger.new do |config| config.metadata = [:time] config.level = :debug config.output = log_file end Celluloid.logger = $logger end end
init_live_watch()
click to toggle source
# File lib/working_set_cli.rb, line 159 def init_live_watch AppSupervisor.enable_live_watch! if params.key?(:watch) $LIVE_UPDATE_WATCH_PATH = params.key?(:watch) ? (params[:watch] || ".") : false end
init_ncurses()
click to toggle source
# File lib/working_set_cli.rb, line 142 def init_ncurses Ncurses.initscr Ncurses.cbreak # unbuffered input Ncurses.noecho # turn off input echoing Ncurses.nonl # turn off newline translation Ncurses.stdscr.intrflush(false) # turn off flush-on-interrupt Ncurses.stdscr.keypad(true) # turn on keypad mode Ncurses.curs_set(0) # hidden cursor Ncurses.start_color Ncurses.use_default_colors Colors.each_pair do |k,v| Ncurses.init_pair v[:number], v[:pair][0], v[:pair][1] end end
init_socket_file()
click to toggle source
# File lib/working_set_cli.rb, line 164 def init_socket_file $SOCKET_PATH = params[:socket] check_for_existing_socket_file end