Clear terminal window in Node.js readline shell

后端 未结 7 881
长情又很酷
长情又很酷 2021-01-31 05:41

I have a simple readline shell written in Coffeescript:

rl = require \'readline\'
cli = rl.createInterface process.std         


        
7条回答
  •  情话喂你
    2021-01-31 06:14

    You can clear screen using console.log() and escape sequences.

    cli.on 'line', (line) ->
      if line == 'cls'
        console.log("\033[2J\033[0f")
      else
        console.log line
    cli.prompt()
    

提交回复
热议问题