-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
46 lines (36 loc) · 1.41 KB
/
index.js
File metadata and controls
46 lines (36 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';
/* globals console, require, process */
var program = require('commander');
program
.version('0.5.3')
.option('-h, --hostname <hostname>', 'The hostname that will be updated (e.g. mySubdomain.testDomain.com)')
.option('-u, --username <username>', 'The username for your domain')
.option('-p, --password <password>', 'The password for your domain')
.option('-s, --start', 'It will start the update process')
.option('-l, --list', 'It will list the existing hosts')
.option('-d, --delete <delete>', 'The hostname to delete out of the configuration')
.option('-i, --interval <interval>', 'The interval for the update procedure. If -i is not specified it is every 5 minutes')
.parse(process.argv);
var hostname = program.hostname;
var username = program.username;
var password = program.password;
if(process.argv.length === 2)
program.help();
if(program.start) {
var updater = require('./lib/updater');
if(program.interval)
updater.start(program.interval);
else
updater.start();
}
var config = require('./lib/config');
if(program.list) {
config.listHosts();
}
if(hostname && username && password) {
console.log('You added a new host to refresh. Hostname:', program.hostname, 'Username:', program.username, 'Password:', program.password);
config.addHost(hostname, username, password);
}
var hostnameToDelete = program.delete;
if(hostnameToDelete)
config.deleteHost(hostnameToDelete);