-
Notifications
You must be signed in to change notification settings - Fork 4
/
commands.js
36 lines (30 loc) · 897 Bytes
/
commands.js
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
#!/usr/bin/env node
const argv = require('yargs')
.default('region', process.env.AWS_DEFAULT_REGION ? process.env.AWS_DEFAULT_REGION : 'us-east-1')
.default('table', 'credential-store')
.argv;
const Credstash = require('./index');
const command = argv._[0];
const itemName = argv._[1];
const value = argv._[2];
const credstash = new Credstash(argv.region, argv.table);
switch (command) {
case 'get':
credstash.get(itemName, (err, item) => {
if (err) {
return console.log(err);
}
console.log(item);
});
break;
case 'put':
credstash.put(itemName, value, (err) => {
if (err) {
return console.log(err);
}
console.log(`Item ${itemName} pushed to credstash`);
});
break;
default:
break;
}