-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
32 lines (24 loc) · 782 Bytes
/
app.js
File metadata and controls
32 lines (24 loc) · 782 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
28
29
30
31
32
#!/usr/bin/env node
const readline = require('readline')
const parseCommand = require('./lib/parseCommand.js')
const request = require('request')
const fs = require('fs')
let args = process.argv.splice(2)
if (args.length > 0)
return parseCommand(args, false)
console.error('Interactive mode is temporary deprecated.')
console.error('Using interactive mode may cause errors.')
console.log(`Type "exit" to exit interactive mode`)
let input = readline.createInterface({ input: process.stdin, output: process.stdout })
let busy = false
input.on('line', (line) => {
if (busy) return
busy = true
let args = line.split(' ')
if (args[0] === 'exit') return input.close()
parseCommand(args, true, () => {
input.prompt()
busy = false
})
})
input.prompt()