We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

Commands

Gator is a CLI application, and like many CLI applications, it has a set of valid commands. For example:

  • gator login - sets the current user in the config
  • gator register - adds a new user to the database
  • gator users - lists all the users in the database
  • etc.

We'll be hand-rolling our CLI rather than using a framework like Cobra or Bubble Tea. This will give us a better understanding of how CLI applications work.

Assignment

Let's start with a simple login command. For now, all it will do is set the current user in the config file. Usage:

gator login <username>

We want to add many commands to our CLI, so let's build a flexible system that will allow us to register new commands easily.

If there are fewer than 2 arguments, print an error message to the terminal and exit. Why two? The first argument is automatically the program name, which we ignore, and we require a command name.

Run and submit the CLI tests from the root of your project.