lib/url_status.rb in url-status-1.0.6 vs lib/url_status.rb in url-status-1.0.7

- old
+ new

@@ -12,10 +12,11 @@ module UrlStatus class App def main + # we want to disable the text coloring if we are printing to a # file, or on a platform (like windows) that likely doesn't support # the colors String.disable_colorization = !$stdout.isatty @@ -44,24 +45,34 @@ end def url_list opts = Trollop::options do version "url-status #{UrlStatus::VERSION} (c) 2016 @reednj (reednj@gmail.com)" + banner "Usage: #{$0} [options] [urls...]" opt :config, "YAML config file containing array of urls", :type => :string end if ARGV.empty? + + if opts[:config].nil? && !File.exist?(default_config_file) + Trollop::educate + end + begin - data_file_name = opts[:config] || "#{ENV['HOME']}/sites.yaml" + data_file_name = opts[:config] || default_config_file YAML.load_file(data_file_name) rescue => e puts "Could not open '#{data_file_name}' (#{e})" exit(false) end else ARGV.clone end + end + + def default_config_file + "#{ENV['HOME']}/sites.yaml" end def get_response(url) url = 'http://' + url unless url.start_with? 'http'