forked from terrcin/augustctl
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·30 lines (24 loc) · 678 Bytes
/
Copy pathcli.js
File metadata and controls
executable file
·30 lines (24 loc) · 678 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
#!/usr/bin/env node
'use strict';
var augustctl = require('./index');
var config = require(process.env.AUGUSTCTL_CONFIG || './config.json');
var op = process.argv[2];
if (typeof augustctl.Lock.prototype[op] !== 'function') {
throw new Error('invalid operation: ' + op);
}
augustctl.scan(config.lockUuid).then(function(peripheral) {
var lock = new augustctl.Lock(
peripheral,
config.offlineKey,
config.offlineKeyOffset
);
lock.connect().then(function() {
return lock[op]();
}).catch(function(e) {
console.error(e.toString());
}).finally(function() {
return lock.disconnect().finally(function() {
process.exit(0);
});
});
});