forked from open-eio/opk-temper1-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtry
More file actions
executable file
·28 lines (25 loc) · 725 Bytes
/
try
File metadata and controls
executable file
·28 lines (25 loc) · 725 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
#!/usr/bin/env node
var temper1x = require("temper1x")
var program = require('commander')
var log = function(msg) {
if (program.verbose) {
console.log(msg)
}
}
var devices = temper1x.getDevices()
program
.option('-p, --path <path>', 'Set a path to the temper1 device. Detect the path by running the detect command.', '')
.option('-s, --scale [scale]', 'Say farenheit if you dont want celsius.', 'celsius')
.option('-v, --verbose', 'Turn on verbose mode')
.parse(process.argv)
temper1x.readTemperature(program.path, function(err, value) {
if (err) {
log(err)
process.exit(1)
}
if (program.scale === 'farenheit') {
value = (value * (9/5)) + 32
}
console.log(value)
process.exit(0)
})