A command-line task manager
The problem
Build a program that keeps a list of tasks and obeys commands from the input: add a task, mark it finished, list the tasks, show counts and remove one. Every mistake in a command is reported clearly and the program carries on.
Requirements
- A Task struct and a Manager type whose methods add, finish, remove and count tasks
- A command loop with bufio.Scanner and a switch on the first word
- Errors returned from methods and printed by main, never a crash
- Output that stays in a fixed order
Technologies
- Go
- Structs and methods
- Slices
- Errors
- bufio
Step by step
- Write the Task and Manager types and print a list of tasks.
- Add one method for each command and test it with a short input.
- Write the command loop and connect each command to its method.
- Add checks for empty lines, missing arguments and unknown task numbers.
Expected result
A reliable console program whose rules live in methods and whose main only reads and prints.
How it is evaluated
- Every command gives the expected result
- Invalid commands print a clear message and change nothing
- Rules, input and output are kept apart
- Names and structure are easy to read
Ways to improve it
- Add an edit command that changes the text of a task
- Add priorities and sort the list by priority
- Write small test functions for the Manager methods