20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/clockker/cli.rb', line 20
def watch
logger = Logger.new(STDERR)
case options[:verbose]
when 'debug'
logger.level = Logger::DEBUG
when 'info'
logger.level = Logger::INFO
when 'warn'
logger.level = Logger::WARN
when 'error'
logger.level = Logger::ERROR
else logger.level = Logger::FATAL
end
logger.debug "Setting verbosity to #{options[:verbose]}"
clockker_config = Clockker::Config.new(
submit_frequency: options[:submit_frequency].to_i,
log_level: options[:verbose],
identifier: options[:identifier]
)
clockker_config.token = options[:token] if options[:token]
clockker_config.region = options[:region] if options[:region]
clockker_config.whitelist = options[:whitelist] if options[:whitelist]
clockker_config.blacklist = options[:blacklist] if options[:blacklist]
clockker_config.development = options[:development] if options[:development]
if options[:token].nil? && clockker_config.token.nil?
puts "You must provide a value for the token, either as a parameter (--token=x) or in the ~/.clockker_config file."
exit
end
if options[:region].nil? && clockker_config.region.nil?
puts "You must provide a value for the server region (e.g. ca-central, us-east, eu-frankfurt, etc.), either as a parameter (--region=x) or in the ~/.clockker_config file."
exit
end
Clockker::Watcher.new(clockker_config, logger: logger)
end
|