Skip to content

Commit

Permalink
Added support for retrieving only expired domains.
Browse files Browse the repository at this point in the history
  • Loading branch information
anderly committed Oct 29, 2014
1 parent a42b62f commit 7a9b347
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
21 changes: 16 additions & 5 deletions lib/commands/domain._js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
var __ = require('underscore');
var util = require('util');
var wrap = require('wordwrap').hard(0, 75);
var datejs = require('datejs');

var Constants = require('../util/constants');
var profile = require('../util/profile');
Expand All @@ -42,19 +43,29 @@ exports.init = function (cli) {

domain.command('list [name]')
.description($('List domains'))
.option('-e --expiring', $('only show expiring domains'))
.execute(function (name, options, _) {
var context = {
subscription: profile.current.getSubscription(options.subscription).id
subscription: profile.current.getSubscription(options.subscription).id,
expiring: options.expiring
};

context.skipCache = true;
var domains = domain.doDomainsGet(context, _);

if (name) {
domains = domains.filter(function (s) {
return utils.ignoreCaseEquals(s.name, name);
});
}
domains = domains.filter(function (s) {
return utils.ignoreCaseEquals(s.name, name);
});
}

if (options.expiring) {
domains = domains.filter(function (s) {
var within30Days = (30).days().fromNow();
var expires = Date.parse(s.expires_on);
return expires >= Date.today() && expires <= within30Days;
});
}

cli.interaction.formatOutput(domains, function (data) {
if (data.length > 0) {
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/domain/domainclient._js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var cacheUtils = require('../../util/cacheUtils');
var __ = require('underscore');

var utils = require('../../util/utils');
var util = require('util');

//var dnsimple = require('dnsimple');

Expand All @@ -42,7 +43,7 @@ __.extend(DomainClient.prototype, {
// //self.ensureSpaces(context, _);
// //blah

progress = self.cli.interaction.progress($('Getting domains'));
progress = self.cli.interaction.progress(util.format($('Getting%s domains'), context.expiring ? $(' expiring') : ''));
try {
var domains = dns.domains.list(false, _);

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"caller-id": "0.1.x",
"colors": "0.x.x",
"commander": "1.0.4",
"datejs": "1.0.0-rc1",
"dnsimple": "git://github.com/fvdm/nodejs-dnsimple.git#master",
"easy-table": "0.0.1",
"event-stream": "3.1.5",
Expand Down

0 comments on commit 7a9b347

Please sign in to comment.