Skip to content

Instantly share code, notes, and snippets.

@LightAndLight
Last active August 27, 2021 09:27
Show Gist options
  • Save LightAndLight/e014ad039d9ff5aac0e23fe9f913da3a to your computer and use it in GitHub Desktop.
Save LightAndLight/e014ad039d9ff5aac0e23fe9f913da3a to your computer and use it in GitHub Desktop.
To-do list spec

Write a command line todo-list app.

Running the program should load you into a REPL (read-eval-print loop).

A user should be able to enter a command by typing: COMMAND:argument i.e. a single word command followed by a colon, with everything to the right of the colon being the argument, then hitting the enter key. If a command takes no argument then the user should be allowed to omit the colon.

Implement the following 5 commands:

  1. "quit" (takes no arguments) - exits the application

  2. "help" (takes no arguments) - prints these command descriptions

  3. "add" (takes any non-empty string as an argument) - adds its argument to the end of the todo-list

  4. "remove" (takes a non-negative integer less than the size of the todo-list as an argument) - removes the element at the index specified by the argument

  5. "list" (takes no arguments) - prints the todo-list to the screen in the format "element_position - message"

If the user enters an invalid command or an invalid argument, print a helpful error message and let them try again.

Extra credit:

  • "save" (takes a filepath as an argument) - saves the todo-list to the specified file
  • "load" (takes a filepath as an argument) - replaces the current todo-list with one contained in the specified file

Extra extra credit:

If the user has made unsaved changes and tries to quit or load, they should first be presented with an interactive dialog that will help them save to a file if they'd like to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment