Skip to content

Commit 945f883

Browse files
committed
Add mock --ip option.
1 parent 071f9c0 commit 945f883

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

cli.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ program
102102
.description('mock a Tuya device for local testing')
103103
.option('-i, --id [id]', 'ID to use for mock device')
104104
.option('-k, --key [key]', 'key to use for mock device')
105+
.option('-a, --ip [key]', 'IP/host name to use for mock device')
105106
.option('-s, --state [state]', 'inital state to use for device', JSON.stringify({1: true, 2: false}))
106107
.option('-u, --disableUDP', 'disable the UDP broadcast')
107108
.action(options => {

lib/mock.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ async function mock(config, options) {
1111
}
1212

1313
// Create stub device
14-
const device = new Stub({id: options.id, key: options.key, state: JSON.parse(options.state)});
14+
const device = new Stub({id: options.id, key: options.key, ip: options.ip, state: JSON.parse(options.state)});
15+
if (options.ip != null)
16+
device.ip = options.ip;
1517

1618
// Start stub server
1719
await device.startServer();

0 commit comments

Comments
 (0)