Class: Fabulous::Nameservers
- Inherits:
-
Thor
- Object
- Thor
- Fabulous::Nameservers
- Defined in:
- lib/fabulous/cli.rb
Instance Method Summary collapse
- #get(domain_name) ⇒ Object
-
#initialize(*args) ⇒ Nameservers
constructor
A new instance of Nameservers.
- #set(domain_name, *nameservers) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Nameservers
Returns a new instance of Nameservers.
14 15 16 17 18 |
# File 'lib/fabulous/cli.rb', line 14 def initialize(*args) super @pastel = Pastel.new configure_client end |
Instance Method Details
#get(domain_name) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fabulous/cli.rb', line 21 def get(domain_name) spinner = TTY::Spinner.new("#{@pastel.cyan('⚡')} Fetching nameservers... ", format: :dots) spinner.auto_spin begin nameservers = client.domains.get_nameservers(domain_name) spinner.success(@pastel.green("✓ Found nameservers")) puts puts @pastel.bold.cyan("Nameservers for #{domain_name}:") if nameservers && nameservers.any? nameservers.each_with_index do |ns, i| puts " #{@pastel.dim("#{i + 1}.")} #{@pastel.white(ns)}" end else puts @pastel.yellow(" No nameservers found") end rescue Fabulous::Error => e spinner.error(@pastel.red("✗ Error: #{e.message}")) exit 1 end end |
#set(domain_name, *nameservers) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fabulous/cli.rb', line 45 def set(domain_name, *nameservers) if nameservers.length < 2 puts @pastel.red("✗ Error: At least 2 nameservers required") exit 1 end puts @pastel.cyan("Setting nameservers for #{domain_name}:") nameservers.each_with_index do |ns, i| puts " #{i + 1}. #{ns}" end spinner = TTY::Spinner.new("#{@pastel.cyan('⚡')} Updating... ", format: :dots) spinner.auto_spin begin if client.domains.set_nameservers(domain_name, nameservers) spinner.success(@pastel.green("✓ Nameservers updated successfully")) else spinner.error(@pastel.red("✗ Failed to update nameservers")) end rescue Fabulous::Error => e spinner.error(@pastel.red("✗ Error: #{e.message}")) exit 1 end end |