REPL stands for "read-eval-print loop". It's a common type of program that allows for interactivity. You type in a command, and the program evaluates it and prints the result. You can then type in another command, and so on.
Your native terminal's command line is a REPL! Our Pokedex will also be a REPL. In this step, we're just going to build the bones of the REPL: a loop that parses and cleans an input and prints the first word back to the user. Here is what your program should be able to do after this step:
> npm run dev
Pokedex > help me
help
Pokedex > Exit
exit
Pokedex > WHAT even is a pokeman?
what
Pokedex > is our own custom command line prompt. The program waited and recorded my input (in the first instance, help me) and didn't continue until I pressed enter.
Use .js extensions when importing files. We're using a bare-bones setup without a bundler, so Node can't import .ts. For example, this is my main.ts:
// repl.js actually refers to repl.ts
import { startREPL } from "./repl.js";
function main() {
startREPL();
}
main();
input: a readable stream (use process.stdin)output: a writable stream (use process.stdout)prompt: a string to print to output whenever rl.prompt() is calledwagslane@MacBook-Pro-2 pokedexcli % npm run dev
Pokedex > well hello there
Your command was: well
Pokedex > Hello there
Your command was: hello
Pokedex > POKEMON was underrated
Your command was: pokemon
You can terminate the program by pressing ctrl+c.
npm run dev | tee repl.log
CHARMANDER is better than bulbasaur.Pikachu is kinda mean to ash.ctrl+c.Run and submit the CLI tests.