Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- process.stdout.write('\x1Bc');
- const myRL = require('serverline');
- myRL.init();
- myRL.setCompletion(['1', '2', '3']);
- myRL.setPrompt('> ');
- function SimpleCommand() {
- let globalResolve;
- this.read = () => {
- return new Promise((resolve, reject)=> {
- if (!gresolve) {
- myRL.on('line', function (line) {
- globalResolve(line);
- if (myRL.isMuted())
- myRL.setMuted(false)
- })
- }
- globalResolve = resolve;
- })
- };
- }
- (async ()=> {
- const sc = new SimpleCommand();
- while (true) {
- const cmd = await sc.read();
- console.log('your command is ', cmd);
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement