As we add more commands, the statefulness of our program is going to increase. We're going to shove all that state into a State object. There are a few goals for this object:
commands registry (looking at you help command)readline interface created with createInterface so that the exit command can clean up after itselfIn the future there will be even more shared state, and we want a simple function signature that all the callbacks can conform to, namely:
callback: (state: State) => void;
import { createInterface, type Interface } from "readline";
Now that we've done all this... nothing's changed! Our code should still work the exact same way. Womp womp. Welcome to refactoring! Refactoring is actually a super important skill that you'll spend a lot of time doing as a developer. It's all about updating the structure (but not behavior) of your code to make it easier to read, maintain, and extend.
Run and submit the CLI tests.