mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
feat: add debug mode to client
This commit is contained in:
1 parent
e16b328892
commit
d9836318db
1 file changed
+8
-2
@@ -14,6 +14,12 @@ stdin.setRawMode(true)
|
|||||||
stdin.resume()
|
stdin.resume()
|
||||||
stdin.setEncoding('utf8')
|
stdin.setEncoding('utf8')
|
||||||
|
|
||||||
|
function debug(...args) {
|
||||||
|
if (program.opts().debug) {
|
||||||
|
console.debug(...args)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function createdSession() {
|
async function createdSession() {
|
||||||
console.log('Creating a new session...')
|
console.log('Creating a new session...')
|
||||||
const res = await fetch(`${program.opts().host}/api/v1/sessions`, {
|
const res = await fetch(`${program.opts().host}/api/v1/sessions`, {
|
||||||
@@ -73,8 +79,7 @@ async function connect(sessionId) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
socket.on('graph', (data) => {
|
socket.on('graph', (data) => {
|
||||||
console.log('receive graph:')
|
debug('receive graph:', data)
|
||||||
console.log(data)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
socket.on('close', function close() {
|
socket.on('close', function close() {
|
||||||
@@ -107,6 +112,7 @@ async function main() {
|
|||||||
program
|
program
|
||||||
.option('-s, --session <string>', 'Session ID')
|
.option('-s, --session <string>', 'Session ID')
|
||||||
.option('-c, --create', 'Create a new session')
|
.option('-c, --create', 'Create a new session')
|
||||||
|
.option('-d, --debug', 'Debug mode')
|
||||||
.option(
|
.option(
|
||||||
'-h, --host <string>',
|
'-h, --host <string>',
|
||||||
'Server host',
|
'Server host',
|
||||||
|
|||||||
Reference in new issue
Block a user