function updatePrompt() { var prompt = 'wechat'; if (wechat.isLogined()) { prompt = chalk.bold.blue(wechat.getUser()); var chat = wechat.getChat(); if (chat) { prompt += chalk.yellow(' => ') + chalk.bold.blue(chat); } } rl.setPrompt(prompt + chalk.yellow('> ')); }
// ask question rl.question(">>What is the meaning of life? ", function(answer) { console.log("About the meaning of life, you said " + answer); rl.setPrompt(">> "); rl.prompt(); });
socket.on('loggedin', data => { if (data.error) { return consoleOut(data.error); } consoleOut('Login successful!'); nick = data.username; authToken = data.token; readline.setPrompt(color(`${nick}: `, 'red')); readline.prompt(); });
rl.question(`\n${yellow('Username')}: `, mail => { username = mail; rl.setPrompt(`${yellow('Password')}: `); rl.prompt(); rl.on('line', pass => { password = pass; rl.close(); }); });
rl.setPrompt('> '); rl.prompt();
rl.question(`What is ${ num1 } + ${ num2 }? \n`, (userInput) => { if(userInput.trim() == answer){ // console.log('Correct!!'); rl.close(); }else{ rl.setPrompt('Incorrect response please try again \n'); rl.prompt(); } rl.on('line', (userInput) => { if(userInput == answer){ rl.close(); }else{ rl.setPrompt(`Your anser of ${ userInput } is incorrect,try again \n`); rl.prompt(); } }); });