SHARE
TWEET

Untitled

a guest Sep 16th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. process.stdout.write('\x1Bc');
  2.  
  3. const myRL = require('serverline');
  4.  
  5. myRL.init();
  6. myRL.setCompletion(['1', '2', '3']);
  7. myRL.setPrompt('> ');
  8.  
  9.  
  10. function SimpleCommand() {
  11.     let globalResolve;
  12.     this.read = () => {
  13.         return new Promise((resolve, reject)=> {
  14.             if (!gresolve) {
  15.                 myRL.on('line', function (line) {
  16.                     globalResolve(line);
  17.                     if (myRL.isMuted())
  18.                         myRL.setMuted(false)
  19.                 })
  20.             }
  21.             globalResolve = resolve;
  22.         })
  23.     };
  24. }
  25.  
  26. (async ()=> {
  27.     const sc = new SimpleCommand();
  28.     while (true) {
  29.         const cmd = await sc.read();
  30.         console.log('your command is ', cmd);
  31.     }
  32. })();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top