-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·50 lines (45 loc) · 1.18 KB
/
cli.js
File metadata and controls
executable file
·50 lines (45 loc) · 1.18 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
47
48
49
#!/usr/bin/env node
var util = require('util'),
kpe = require('./lib/KeePassEditor.js'),
_ = require('underscore'),
prompt = require('prompt'),
argv = require('yargs')
.count('verbose')
.alias('v','verbose')
.demand(['database'])
.alias('d','database')
.usage('$0 --database [path]')
.argv;
prompt.message = '';
prompt.delimiter = '';
var openDb = function(db, pw){
var obj = new kpe(db, pw);
obj.on('open', function() {
console.log('opened database');
obj.getGroups(function(err, data){
console.log('Groups:');
_.each(data, function(i){
console.log(' -%s',i);
});
});
});
};
if(!argv.key) {
prompt.start();
prompt.colors = false;
prompt.get([{
name: 'password',
description: 'Enter database password:',
required: true,
hidden: true,
conform: function(value){
return true;
}
}], function(err, results){
if(err){
console.err('error getting credentials');
process.exit(1);
}
openDb(argv.database,results.password);
});
}