Sha256: 55dc7690f91ead1e805648a9f9fe4c2bdc2162306021634b247544a3707e4b87

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

#!/usr/bin/env ruby

require 'optparse'
require 'hosts_updater'

options = { :sources => {} }

OptionParser.new do |opts|
  opts.banner = "Usage: hosts-updater [options]"

  opts.on("-h", "--help", "Show this message") do
    puts opts
    exit
  end

  opts.on("--hosts-file [PATH]", "Path to hosts file to write (default: /etc/hosts)") do |file|
    options[:hosts_file] = file
  end

  opts.on("--hosts-directory [PATH]", "Path to hosts.d config directory (default: /etc/hosts.d/)") do |file|
    options[:hosts_dir] = file
  end

  opts.on("--hosts-auto-name [NAME]", "Name for auto-generated file in hosts.d dir (default: hosts.auto)") do |file|
    options[:hosts_auto_name] = file
  end

  opts.on("--hosts-custom-name [NAME]", "Name for custom hosts file in hosts.d dir (default: hosts.custom)") do |file|
    options[:hosts_custom_name] = file
  end

  opts.on("--hosts-whitelist-name [NAME]", "Name for file with whitelisted domains in hosts.d dir (defaule: hosts.whitelist)") do |file|
    options[:hosts_whitelist_name] = file
  end


  opts.on("-i", "--ip", "Redirect all blacklisted domains to following IP (default: 0.0.0.0)") do |ip|
    options[:id] = ip
  end

  opts.on("-u", "--[no-]update", "Update sources") do |u|
    options[:update] = u
  end

  HostsUpdater::SOURCES.each do |source_key, source_data|
    opts.on("--skip-#{source_key}", "Skip downloading #{source_data[1]} (#{source_data[0]})") do |s|
      options[:sources][source_key] = false
    end
  end

  opts.on("-q", "--quiet", "Run completely silently") do |q|
    options[:quiet] = q
  end

  opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
    options[:verbose] = v
  end
end.parse!

HostsUpdater.new(options).run

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hosts_updater-1.0.2 bin/hosts-updater
hosts_updater-1.0.1 bin/hosts-updater