forked from jtangelder/denon-remote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli
More file actions
27 lines (19 loc) · 676 Bytes
/
cli
File metadata and controls
27 lines (19 loc) · 676 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
#!/usr/bin/env coffee
connection = new (require './lib/connection')
command = new (require './lib/commands')(connection)
process.stdin.resume()
process.stdin.setEncoding('utf8')
connection.connect process.argv[2] || "denon", 23, ()->
process.stdout.write "connected to the receiver\r"
process.stdin.on 'data', (chunk)->
[cmd, param] = chunk.split(" ").map((val)-> val.trim())
if command[cmd]
command[cmd](param)
else
connection.send cmd.toUpperCase(), param
connection.response (cmd, value)->
if cmd is 'info'
for index,line of value
process.stdout.write "- #{line.trim()}\n"
else
process.stdout.write "- #{cmd}: #{value}\r"