This program allows a user to manage a todo list from the command line. Users can add a tasks, delete a task, clear all tasks, and exit the program. Tasks are stored on the system in the file "tasks.txt" and in the program as a slice. User input is read using bufio and manipulates the task list using a switch statement. The Task type is a struct with an ID and name. The program outputs the current task list and available commands to the user.
To run this program, you will need Go installed on your system. You can download it from:
- Clone the repository.
- (Optional) In the terminal, traverse to the project directory.
- Run the following command: go run todolist.go.
- If terminal's working directory is not the project directory, replace filename 'todolist.go' with file path.
Upon running the program, the user will be presented with the current task list (or an empty task list, if the task list is empty) and the available options. To select an option, the user should enter the corresponding number and return. The program will then execute the selected option and loop back to the beginning.
To add a new task to the list, select option 1 and enter a task description when prompted.
- Does not add task to the list if an empty task description is entered.
- Attempts to overwrite "tasks.txt" with an updated task list.
To delete a task from the list, select option 2 and enter the task ID when prompted.
- Checks if there are any tasks to delete.
- Iterates over the task list to check if the task ID exists.
- If it exists, remove the task from the list and reorder the task ID.
- If successful, attempt to overwrite "tasks.txt" file with an updated task list.
To clear all tasks from the list, select option 3.
- Attempts to overwrite "task.txt" file with an empty task list.
To exit the program, select option 4.