Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  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. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement