Skip to content
This repository has been archived by the owner on Apr 17, 2020. It is now read-only.

Implement -k switch to use self signed certificates, cli parameters cleanup #7

Merged
merged 2 commits into from
Jan 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ Options:
-d, --devices File location of device list (must end with .json).
-g, --password Gateway password (to enable gateway light change)
-h, --help Show help
-l, --logging possiblevalues: "error", "warn","info","debug"
[default: "info"]
-l, --logging Logging level [choices: "error", "warn", "info", "debug"] [default: "info"]
-m, --mqtt mqtt broker url. See https://github.com/svrooij/node-xiaomi2mqtt#mqtt-url
[default: "mqtt://127.0.0.1"]
-k, --insecure accept self singed-certificates when using TLS. See https://github.com/mqttjs/MQTT.js#mqttclientstreambuilder-options
[boolean] [default: false]
-n, --name instance name. used as mqtt client id and as topic prefix
[default: "xiaomi"]
--version Show version number
Expand Down
3 changes: 2 additions & 1 deletion src/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ function start () {
message: 0,
qos: 0,
retain: true
}
},
rejectUnauthorized = !config.insecure
}

mqttClient = mqtt.connect(config.mqtt, mqttOptions)
Expand Down
8 changes: 7 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,30 @@ const config = require('yargs')
.describe('d', 'File location of device list (must end with .json).')
.describe('g', 'Gateway password (to enable gateway light change)')
.describe('h', 'Show this help')
.describe('l', 'possiblevalues: "error", "warn","info","debug"')
.describe('l', 'Logging level')
.describe('m', 'mqtt broker url. See https://github.com/mqttjs/MQTT.js#connect-using-a-url')
.describe('k', 'accept self singed-certificates when using TLS. See https://github.com/mqttjs/MQTT.js#mqttclientstreambuilder-options')
.describe('n', 'instance name. used as mqtt client id and as topic prefix')
.boolean('k')
.alias({
d: 'devices',
g: 'password',
h: 'help',
l: 'logging',
m: 'mqtt',
k: 'insecure',
n: 'name'
})
.choices('l', ['error', 'warn', 'info', 'debug'])
.default({
l: 'info',
m: 'mqtt://127.0.0.1',
k: false,
n: 'xiaomi'
})
.version()
.help('help')
.wrap(null)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this row do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that disables yargs default usage output (which is 80 columns) basically demaning -h usage output wrapping to the terminal. (ref doc .wrap )[https://github.com/yargs/yargs/blob/HEAD/docs/api.md#wrapcolumns]. It's purely cosmetic, unfortunately I couldn't find a way to wrap properly by using something like .wrap(yargs.terminalWidth()) as suggested in the docs.

.argv

module.exports = config