#!/usr/bin/env ruby # Hack to allow testing with Aruba (for now) $:.push File.expand_path(File.join("..", "..", "lib"), __FILE__) require 'hobo' require 'slop' require 'teerb' require 'tmpdir' error_handler = Hobo::ErrorHandlers::Friendly.new Hobo.ui = Hobo::Ui.new Hobo.logger = Logger.new(STDOUT) Hobo.logger.level = Logger::WARN # Options parsed here will be hidden from the main app slop = Slop.parse! do on '--debug', 'Enable debugging' do error_handler = Hobo::ErrorHandlers::Debug.new debug_log = File.open(File.join(Dir.tmpdir, 'hobo_debug.log'), 'w+') Hobo.logger = Logger.new(TeeRb::IODelegate.new(STDOUT, debug_log)) Hobo.logger.level = Logger::DEBUG end on '--ansi', 'Enable / disable ansi output', :invertable => true do Hobo.ui.use_color self.to_hash[:ansi] end on '--log-level=', 'Set log level' do level = self.to_hash[:'log-level'].upcase Hobo.logger.level = Logger.const_get(level) if [ 'DEBUG', 'INFO' ].include? level end end Hobo.logger.formatter = proc do |severity, datetime, progname, msg| "#{datetime.strftime("%Y-%m-%d %H:%M:%S")}: #{severity}: #{msg}\n" end begin Hobo::Lib::HostCheck.check(:filter => /not_using_system_ruby/) Hobo.cli = Hobo::Cli.new(slop: slop) Hobo.cli.start rescue Exception => error exit error_handler.handle(error) end