Skip to content

Commit 6ffbdec

Browse files
committed
Added domain renew functionality.
1 parent 04c59af commit 6ffbdec

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed

lib/commands/domain/domain._js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,56 @@ exports.init = function (cli) {
514514

515515
},
516516

517+
domain.renewCommand = function (name, options, _) {
518+
var context = {
519+
subscription: profile.current.getSubscription(options.subscription).id,
520+
domain: {
521+
name: name
522+
},
523+
flags: {
524+
renew_whois_privacy: false
525+
}
526+
};
527+
528+
var self = this;
529+
self.promptForDomainName(context, _);
530+
531+
if (options.whois) {
532+
context.flags.renew_whois_privacy = true;
533+
}
534+
535+
var domains = context.domain.name.split(',');
536+
var results = [];
537+
var domainClient = domain.client(context);
538+
539+
var shouldContinue = options.quiet || cli.interaction.confirm($('Are you sure you want to renew the specified domains? '), _);
540+
if (!shouldContinue) {
541+
log.warn('Domain renewal cancelled.');
542+
return;
543+
}
544+
545+
results = async.map(domains, function(d, _) {
546+
domainClient.renewDomain({
547+
subscription: context.subscription,
548+
domain: {
549+
name: d
550+
},
551+
flags: {
552+
renew_whois_privacy: context.flags.renew_whois_privacy
553+
}
554+
}, _);
555+
}, _);
556+
results = results.sort(sortByName);
557+
558+
log.help('Successfully renewed the following domains:');
559+
log.table(results, function (row, item) {
560+
row.cell($('Id'), item.id);
561+
row.cell($('Name'), item.name);
562+
row.cell($('Expires'), item.expires_on);
563+
});
564+
565+
},
566+
517567
domain.command('list [name]')
518568
.description($('List domains'))
519569
.option('-e --expiring', $('only show expiring domains'))
@@ -567,6 +617,13 @@ exports.init = function (cli) {
567617
.option('-q --quiet', $('quiet mode, do not ask for confirmation'))
568618
.execute(domain.autoRenewCommand);
569619

620+
domain.command('renew [name]')
621+
.usage('[options] [name]')
622+
.description($('Renew a domain'))
623+
.option('-w --whois', $('Renew associated Whois Privacy. Defaults to false.'))
624+
.option('-q --quiet', $('quiet mode, do not ask for confirmation'))
625+
.execute(domain.renewCommand);
626+
570627
domain.client = function(options) {
571628
return new DomainClient(cli, options.subscription);
572629
};

lib/commands/domain/domains/domainclient._js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,25 @@ __.extend(DomainClient.prototype, {
205205
return result;
206206
},
207207

208+
renewDomain: function (context, _) {
209+
var self = this;
210+
211+
var dns = self.createDnsimpleClient(context.subscription).create(_);
212+
213+
var domainName = context.domain.name;
214+
var renewWhois = context.flags.renew_whois_privacy;
215+
216+
var result;
217+
var progress = self.cli.interaction.progress(util.format($('Renewing domain %s'), domainName));
218+
try {
219+
result = dns.domains.renew(domainName, renewWhois, _);
220+
}
221+
finally {
222+
progress.end();
223+
}
224+
return result;
225+
},
226+
208227
getRecords: function (context, _) {
209228
var self = this;
210229

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 <[email protected]>"
66
],
7-
"version": "0.2.12",
7+
"version": "0.2.13",
88
"description": "DNSimple Command Line tool",
99
"tags": [
1010
"dnsimple",

0 commit comments

Comments
 (0)