-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcli.js
59 lines (57 loc) · 1.85 KB
/
cli.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const yargs = require('yargs');
const argv = yargs
.option('serialport', {
alias: 's',
description: 'Serial port your BMS is connected to (e.g -s /dev/ttyUSB0)',
type: 'string',
})
.option('baudrate', {
alias: 'b',
description: 'The baud rate to use for serial communications, defaults to 9600 (e.g -b 14400)',
type: 'integer',
default: 9600
})
.option('mqttbroker', {
alias: 'm',
description: 'The address of your MQTT Broker (e.g -m 192.168.0.10)',
type: 'string',
})
.option('mqttuser', {
alias: 'u',
description: 'The username for your MQTT Broker (e.g -u mqttUser)',
type: 'string',
})
.option('mqttpass', {
alias: 'p',
description: 'The password for your MQTT Broker (e.g -p mqttPass)',
type: 'string',
})
.option('mqtttopic', {
alias: 't',
description: 'MQTT topic to publish to defaults to \'NodeJBD\' (e.g -t MyTopic)',
type: 'string',
default: 'NodeJBD'
})
.option('pollinginterval', {
alias: 'i',
description: 'How frequently to poll the controller in seconds, defaults to 10 (e.g -i 60)',
type: 'integer',
default: 10
})
.option('loglevel', {
alias: 'l',
description: 'Logging level to use, values are trace, debug, info, warn, error, fatal. Defaults to error',
type: 'string',
default: 'info'
})
.choices('loglevel', ['trace', 'debug', 'info', 'warn', 'error', 'fatal'])
.help()
.alias('help', 'h')
.epilogue('For more information, check out the project repository at https://github.com/mickwheelz/NodeJBD')
.env('NODEJBD')
.demandOption('serialport', 'You must specify a serial port')
.wrap(yargs.terminalWidth())
.argv;
module.exports = {
args: argv
};