Skip to content

Commit 92a9b23

Browse files
committed
Added domain record show functionality.
1 parent c9e6647 commit 92a9b23

7 files changed

Lines changed: 68 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ See the [command reference][3] for complete planned command structure.
2828
* Show DNS Records of a specific type (A, CNAME, TXT, NS, etc.) for a specific domain
2929
* Show DNS Records whose content matches a specific filter (e.g. \*spf\*)
3030
* Add DNS Records to a domain
31+
* Show details for a domain DNS Record
3132

3233
---
3334
* Contacts: `(command: dnsimple contact)`

command-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
|- record
4141
|- list [-t --type <type>] [-f --filter <filter>] [domain]
4242
|- add [-r --recordname <recordname>] [-t --type <type>] [-c --content <content>] [domain]
43-
|- show
43+
|- show [-i --id recordid] [domain]
4444
|- update
4545
|- delete
4646
--------------

lib/commands/domain/domain._js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ exports.init = function (cli) {
260260
return domainClient.addRecord(options, callback);
261261
};
262262

263+
domain.doRecordGet = function (options, callback) {
264+
var domainClient = new DomainClient(cli, options.subscription);
265+
return domainClient.getRecord(options, callback);
266+
};
267+
263268
domain.doRecordsGet = function (options, callback) {
264269
var domainClient = new DomainClient(cli, options.subscription);
265270
return domainClient.getRecords(options, callback);

lib/commands/domain/domain.record._js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,41 @@ exports.init = function (cli) {
160160

161161
},
162162

163+
domainRecords.showCommand = function (recordid, name, options, _) {
164+
recordid = cli.interaction.promptIfNotGiven($('Record ID: '), recordid, _);
165+
166+
var context = {
167+
subscription: profile.current.getSubscription(options.subscription).id,
168+
domain: {
169+
name: name
170+
},
171+
record: {
172+
id: recordid
173+
}
174+
};
175+
176+
domain.lookupDomainName(context, _);
177+
178+
var record = domain.doRecordGet(context, _);
179+
180+
var format = [
181+
[$('Id'), 'id'],
182+
[$('Name'), null, function (value) {
183+
if (value.name) {
184+
return value.name;
185+
}
186+
return context.domain.name;
187+
}],
188+
[$('Type'), 'record_type'],
189+
[$('TTL'), 'ttl'],
190+
[$('Content'), 'content'],
191+
[$('Priority'), 'prio'],
192+
];
193+
194+
log.report(format, record);
195+
196+
},
197+
163198
domainRecords.command('list [name]')
164199
.usage('[options] [name]')
165200
.description($('Show your domain dns records'))
@@ -178,4 +213,10 @@ exports.init = function (cli) {
178213
.option('-p --priority <priority>', $('Record Priority.'))
179214
.execute(domainRecords.addCommand);
180215

216+
domainRecords.command('show [recordid] [name]')
217+
.usage('[options] <recordid> [name]')
218+
.description($('Show a dns record for a domain'))
219+
.option('-i --id <recordid>', $('The record id. Use dnsimple domain record list [domain] to see dns records and ids.'))
220+
.execute(domainRecords.showCommand);
221+
181222
};

lib/commands/domain/domains/domainclient._js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,25 @@ __.extend(DomainClient.prototype, {
135135
}
136136
},
137137

138+
getRecord: function (context, _) {
139+
var self = this;
140+
var progress;
141+
142+
var dns = self.createDnsimpleClient(context.subscription).create(_);
143+
var domainName = context.domain.name;
144+
var recordId = context.record.id;
145+
146+
progress = self.cli.interaction.progress(util.format($('Getting record %s for domain %s'), recordId, domainName));
147+
try {
148+
var record = dns.dns.show(domainName, recordId, _);
149+
150+
return record;
151+
}
152+
finally {
153+
progress.end();
154+
}
155+
},
156+
138157
getRecords: function (context, _) {
139158
var self = this;
140159
var progress;

lib/util/profile/subscription.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
'use strict';
1717

1818
var _ = require('underscore');
19-
var dnsimple = require('dnsimple');
2019
var EventEmitter = require('events').EventEmitter;
2120
var url = require('url');
2221
var util = require('util');

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"contributors": [
55
"Anderly, Adam <adam@anderly.com>"
66
],
7-
"version": "0.2.4",
7+
"version": "0.2.5",
88
"description": "DNSimple Command Line tool",
99
"tags": [
1010
"dnsimple",

0 commit comments

Comments
 (0)