-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.js
executable file
·40 lines (31 loc) · 957 Bytes
/
index.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
#! /usr/bin/env node
const colors = require('colors');
const Vorpal = require('vorpal');
const DenonClient = require('./lib/DenonClient');
const setupToolCommands = require('./lib/toolCommands');
const setupDenonCommands = require('./lib/denonCommands');
const denon = new DenonClient();
const cli = Vorpal();
denon.on('connect', ()=> {
const address = denon.socket.remoteAddress;
const port = denon.socket.remotePort;
cli.log(colors.green(`Successfully connected to ${address}:${port}`));
});
denon.on('error', err => {
cli.log(colors.red('Something went wrong'), err);
denon.end();
});
denon.on('close', ()=> {
cli.log(colors.red('Connection closed'));
});
denon.on('data', buffer => {
cli.log(colors.magenta(buffer.toString().trim()));
});
cli
.localStorage('denon-remote-v1')
.history('denon-remote-v1')
.delimiter('denon$')
.show();
setupToolCommands(cli, denon);
setupDenonCommands(cli, denon);
cli.execSync('connect');