-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·34 lines (29 loc) · 865 Bytes
/
index.js
File metadata and controls
executable file
·34 lines (29 loc) · 865 Bytes
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
#!/usr/bin/env node
var Provider = require('./src/Provider');
module.exports = Provider;
require('main')
.usage(['Usage: ./tempmail <provider> [emailAddress]', '',
'- By specifying only a provider, it will return a new email address.',
'- Specifying an email will return the inbox (JSON).'
].join('\n'))
.run(function(argv, exit, help) {
var providerName = argv._[0];
var emailAddress = argv._[1];
if (!providerName) { exit(1, help); }
var provider = new Provider(providerName);
if (!emailAddress) {
// create a new email
provider.newTempEmail(provider).then(function(tempEmail) {
exit(tempEmail.getAddress());
}).otherwise(function(error) {
exit(1, error);
});
} else {
// fetch the inbox
provider.readEmailAddress(emailAddress).then(function(inbox) {
exit(inbox);
}).otherwise(function(error) {
exit(1, error);
});
}
});