class Esgob::CLI
Public Class Methods
start(args = ARGV, config = {})
click to toggle source
Calls superclass method
# File lib/esgob/cli.rb, line 19 def self.start(args = ARGV, config = {}) config[:shell] ||= Thor::Base.shell.new begin super(args, config) rescue Esgob::ServerError => err $stderr.puts config[:shell].set_color("=> Error: #{err.message} [#{err.code}]", :red, :bold) rescue Esgob::UnconfiguredError => err $stderr.puts config[:shell].set_color("=> Error: #{err.message}", :red, :bold) $stderr.puts "Use the 'esgob config' command to create a configuration file." end end
Public Instance Methods
account()
click to toggle source
# File lib/esgob/cli.rb, line 41 def account client.accounts_get.each_pair do |k, v| say sprintf("%8s: %s\n", k, v) end end
config()
click to toggle source
# File lib/esgob/cli.rb, line 32 def config config = Esgob::Config.new config.account = ask("What is your Esgob account name?") config.key = ask("What is your Esgob key?") config.save say "Configuration written to #{config.filepath}" end
domains()
click to toggle source
# File lib/esgob/cli.rb, line 48 def domains print_table( [['Domain', 'Type']] + [['------', '----']] + client.domains_list.map { |h| [h[:domain], h[:type]] } ) end
slaves()
click to toggle source
# File lib/esgob/cli.rb, line 57 def slaves print_table( [['Domain', 'Master IP']] + [['------', '---------']] + client.domains_slaves_list.to_a ) end
slaves_add(domain, masterip)
click to toggle source
# File lib/esgob/cli.rb, line 66 def slaves_add(domain, masterip) check_action do client.domains_slaves_add(domain, masterip) end end
slaves_delete(domain)
click to toggle source
# File lib/esgob/cli.rb, line 73 def slaves_delete(domain) check_action do client.domains_slaves_delete(domain) end end
slaves_sync(filename, masterip)
click to toggle source
# File lib/esgob/cli.rb, line 97 def slaves_sync(filename, masterip) domains = [] File.foreach(filename) do |line| domains << line.strip.split(/\s+/).first end check_action do client.domains_slaves_sync(domains, masterip) end end
slaves_transfer(domain)
click to toggle source
# File lib/esgob/cli.rb, line 81 def slaves_transfer(domain) check_action do client.domains_slaves_forcetransfer(domain) end end
slaves_update(domain, masterip)
click to toggle source
# File lib/esgob/cli.rb, line 89 def slaves_update(domain, masterip) check_action do client.domains_slaves_updatemasterip(domain, masterip) end end
soacheck(domain)
click to toggle source
# File lib/esgob/cli.rb, line 110 def soacheck(domain) response = client.domains_tools_soacheck(domain) print_table( [['Identifier', 'Type', 'Country', 'SOA', 'Response']] + [['----------', '----', '-------', '---', '--------']] + response[:responses][:masters].map do |node| [node[:ip], "master", '', node[:soa], node[:response]] end + response[:responses][:anycastnodes].map do |node| [node[:ref], 'anycast', node[:country], node[:soa], node[:response]] end ) end
version()
click to toggle source
# File lib/esgob/cli.rb, line 125 def version say "Esgob Ruby Client version #{Esgob::VERSION}" end