class Dnsblim::CLI::Tables::AdditionTable
Public Class Methods
new()
click to toggle source
# File lib/dnsblim/cli/tables.rb, line 255 def initialize @hl = HighLine.new(STDIN, STDOUT, 120, 20, 2, 0) HighLine.use_color = true end
Public Instance Methods
run(obj, options)
click to toggle source
# File lib/dnsblim/cli/tables.rb, line 260 def run(obj, options) if options[:quiet] STDERR.puts "Suppressing output due to --quiet" else @hl.say("<%= Paint['Contacting API', 'green'] %>") case options[:additions] when 'single' @hl.indent(1, "<%= Paint['Attempting to add #{options[:ip_addrs].join('')} ...', 'orange'] %>") if options[:duplicates].include? options[:ip_addrs].first @hl.indent(2, "<%= Paint['Error', 'red'] %>: #{options[:ip_addrs].join('')} already in database.") else @hl.indent(2, "<%= Paint['Added #{options[:ip_addrs].join('')}', :green] %>") end @hl.indent(1, "<%= Paint['complete', 'orange'] %>") when 'multiple' options[:ip_addrs].each do |ip| @hl.indent(1, "<%= Paint['Attempting to add #{ip} ...', 'orange'] %>") if options[:duplicates].include? ip @hl.indent(2, "<%= Paint['Error', 'red'] %>: #{ip} already in database.") elsif !options[:duplicates].include? ip @hl.indent(2, "<%= Paint['Added #{ip}', :green] %>") end @hl.indent(1, "<%= Paint['complete', 'orange'] %>") end else raise ArgumentError( <<-RAISE.squish case block in Dnsblim::CLI::Tables::AdditionTable#run has received something other than 'single' or 'multiple' THIS IS A BUG RAISE ) end if options[:message] == %w[failure duplicates] @hl.say("<%= Paint['failure', 'red'] %>.. <%= Paint['ALL IPs WERE DUPLICATES', 'red'] %>") elsif options[:message] == %w[success duplicates] @hl.say("<%= Paint['complete', 'green'] %>.. <%= Paint['with duplicates', 'orange'] %>:") @hl.say("Duplicates: #{options[:ip_addrs].join(', ')}") elsif options[:message] == %w[success] @hl.say("<%= Paint['complete', 'green'] %>") end end end