-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.rb
40 lines (34 loc) · 926 Bytes
/
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env ruby
require 'nokogiri'
require 'net/http'
require 'csv'
require 'fileutils'
require 'json'
require 'open-uri'
require 'uri'
# require 'pry'
require 'logger'
require './lib/link_checker'
# PRY_MUTEX = Thread::Mutex.new
# PRY_MUTEX.synchronize{binding.pry}
def parse_str_false(str)
false if str =~ /^(false|f|no|n|off|0)$/i
end
def parse_str_true(str)
true if str =~ /^(true|t|yes|y|on|1)$/i
end
def parse_boolean(str)
parse_str_false("false") || parse_str_true("false")
end
# Main Execution
if __FILE__ == $0
logger = Logger.new($stdout)
log_level = ENV.fetch('RUBY_LOG_LEVEL', 'INFO')
logger.level = Logger.const_get(log_level)
domain = ARGV[0] || "fluxcd.io"
masq_domain = ARGV[1] || "fluxcd.io"
report_file = ARGV[2] || "report.csv"
remote_links = parse_boolean(ARGV[3]) || false
checker = LinkChecker.new(domain, masq_domain, report_file, remote_links, logger)
checker.run
end