Created
April 16, 2020 08:12
-
-
Save svsh227/fe15b336543f4f01444fcd74360add57 to your computer and use it in GitHub Desktop.
Create init script to start the CLI application:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cli.init = function () { | |
/* Send the start message to the console in dark blue. */ | |
console.log(‘\x1b[33m % s\x1b[0m’, ‘CLI is running’); | |
/* Start the interface */ | |
var _interface = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
prompt: ‘>’ | |
}) | |
/* Create an initial prompt */ | |
_interface.prompt(); // Will wait for input /* Handle each line of input separately. */ | |
_interface.on(‘line’, function (str) { /* Send to input processor. */ | |
cli.processInput(str); /* re-initialize the prompt afterwards. */ | |
_interface.prompt(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment