115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'lib/fabulous/cli.rb', line 115
def add(domain_name)
type = @prompt.select("Choose record type:", %w[A AAAA CNAME MX TXT])
case type
when "A"
hostname = @prompt.ask("Hostname (e.g., www or @ for root):")
ip = @prompt.ask("IP Address:")
ttl = @prompt.ask("TTL:", default: "3600").to_i
spinner = TTY::Spinner.new("#{@pastel.cyan('⚡')} Adding A record... ", format: :dots)
spinner.auto_spin
if client.dns.add_a_record(domain_name, hostname: hostname, ip_address: ip, ttl: ttl)
spinner.success(@pastel.green("✓ A record added"))
else
spinner.error(@pastel.red("✗ Failed to add record"))
end
when "MX"
hostname = @prompt.ask("Mail server hostname:")
priority = @prompt.ask("Priority:", default: "10").to_i
ttl = @prompt.ask("TTL:", default: "3600").to_i
spinner = TTY::Spinner.new("#{@pastel.cyan('⚡')} Adding MX record... ", format: :dots)
spinner.auto_spin
if client.dns.add_mx_record(domain_name, hostname: hostname, priority: priority, ttl: ttl)
spinner.success(@pastel.green("✓ MX record added"))
else
spinner.error(@pastel.red("✗ Failed to add record"))
end
when "CNAME"
alias_name = @prompt.ask("Alias (e.g., blog):")
target = @prompt.ask("Target domain:")
ttl = @prompt.ask("TTL:", default: "3600").to_i
spinner = TTY::Spinner.new("#{@pastel.cyan('⚡')} Adding CNAME record... ", format: :dots)
spinner.auto_spin
if client.dns.add_cname_record(domain_name, alias_name: alias_name, target: target, ttl: ttl)
spinner.success(@pastel.green("✓ CNAME record added"))
else
spinner.error(@pastel.red("✗ Failed to add record"))
end
when "TXT"
hostname = @prompt.ask("Hostname (@ for root):")
text = @prompt.ask("Text value:")
ttl = @prompt.ask("TTL:", default: "3600").to_i
spinner = TTY::Spinner.new("#{@pastel.cyan('⚡')} Adding TXT record... ", format: :dots)
spinner.auto_spin
if client.dns.add_txt_record(domain_name, hostname: hostname, text: text, ttl: ttl)
spinner.success(@pastel.green("✓ TXT record added"))
else
spinner.error(@pastel.red("✗ Failed to add record"))
end
end
rescue Fabulous::Error => e
puts @pastel.red("✗ Error: #{e.message}")
exit 1
end
|