

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Welcome to Build a Pokedex
incomplete
2: Build
incomplete
3: Tests
incomplete
4: REPL
incomplete
5: Help and Exit
incomplete
This lesson's interactive features are locked, please to keep using them
A REPL is only useful if it does something! Our REPL will work using the concept of "commands". A command is a single word that maps to an action.
We're going to support two commands in this step:
help: prints a help message describing how to use the REPLexit: exits the programfunc commandExit() error
This function should print Closing the Pokedex... Goodbye! then immediately exit the program. I used os.Exit(0).
type cliCommand struct {
name string
description string
callback func() error
}
Then I created a map of supported commands:
map[string]cliCommand{
"exit": {
name: "exit",
description: "Exit the Pokedex",
callback: commandExit,
},
}
Welcome to the Pokedex!
Usage:
help: Displays a help message
exit: Exit the Pokedex
You can dynamically generate the "usage" section by iterating over my registry of commands. That way the help command will always be up-to-date with the available commands.
Run and submit the CLI tests from the root of the repo.