Sha256: fdbb647433d27df2da48f5e937866dcc210bce1d86af3cdb616e6d0118c238b2

Contents?: true

Size: 1.35 KB

Versions: 8

Compression:

Stored size: 1.35 KB

Contents

module Dreamy::Command
  class Dns < Base
    
    def list
      dns = @account.dns
      
      if args.length > 0
        filter = args.shift.downcase
        dns = dns.select { |d| d.zone.match(filter) }
      end
      
      if dns.empty?
        display "No DNS records for this account or requested zone not found"
      else
        dns_table = table do |t|
          t.headings = 'Record', 'Type', 'Value'
          dns.each { |d| t << [d.record,d.type,d.value] if d.type != "TXT" }
        end
        display "NOTE: TXT records not displayed (too long)"
        display dns_table
      end
    end
    alias :index :list
    
    def add
      if args.length == 3
        record, type, value = args[0], args[1], args[2]
        @account.dns_add(record,type,value)
        display "Successfully added #{type} record of #{value} to #{record}"
        display "Please wait for DNS to propagate"
      else
        display "Usage: dh dns:add [new record] [type] [value]"
      end
    end
    
    def remove
      if args.length == 3
        record, type, value = args[0], args[1], args[2]
        @account.dns_remove(record,type,value)
        display "Successfully removed #{type} record of #{value} to #{record}"
        display "Please wait for DNS to propagate"
      else
        display "Usage: dh dns:remove [new record] [type] [value]"
      end
    end
    
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
jordan-brough-dreamy-0.5.1 lib/dreamy/commands/dns.rb
sant0sk1-dreamy-0.3.0 lib/dreamy/commands/dns.rb
sant0sk1-dreamy-0.4.1 lib/dreamy/commands/dns.rb
sant0sk1-dreamy-0.5.0 lib/dreamy/commands/dns.rb
sant0sk1-dreamy-0.5.1 lib/dreamy/commands/dns.rb
dreamy-0.5.3 lib/dreamy/commands/dns.rb
dreamy-0.5.2 lib/dreamy/commands/dns.rb
dreamy-0.5.1 lib/dreamy/commands/dns.rb