A command-line todo application written in modern C++ using CMake.
This project was built as a practical exercise in C++ software design, focusing on object-oriented programming, separation of concerns, STL containers, file I/O, persistence, JSON serialization, and CMake-based project organization.
- Add tasks
- List tasks
- Mark tasks as completed
- Remove tasks
- Automatic task ID generation
- Persistent task storage
- JSON-based data storage
- Interactive command-line menu
- Input validation
todo-cli/
├── CMakeLists.txt
├── include/
│ ├── nlohmann/
│ │ └── ... # nlohmann/json headers
│ └── todo/
│ ├── FileStorage.h
│ ├── Task.h
│ └── TodoManager.h
├── src/
│ ├── FileStorage.cpp
│ ├── Task.cpp
│ ├── TodoManager.cpp
│ └── main.cpp
└── build/
The project separates responsibilities between the main components:
Represents an individual todo item.
A task contains:
- ID
- Title
- Completion status
Responsible for todo-related business logic, including:
- Adding tasks
- Removing tasks
- Completing tasks
- Managing the collection of tasks
Responsible for persistence.
It handles:
- Saving tasks to disk
- Loading tasks from disk
- JSON serialization and deserialization
- File I/O
The application uses std::fstream for file operations and nlohmann/json for JSON serialization.
Tasks are stored in:
tasks.json
Example:
[
{
"id": 1,
"title": "Learn C++",
"completed": false
},
{
"id": 2,
"title": "Build Todo CLI",
"completed": true
}
]The persistence flow is:
Save:
std::vector<Task>
↓
JSON objects
↓
JSON array
↓
tasks.json
Load:
tasks.json
↓
JSON
↓
Task objects
↓
std::vector<Task>
- C++20
- CMake
- Ninja
- nlohmann/json
- STL
std::ifstreamstd::ofstream
From the project root:
cmake -S . -B build -G Ninjacmake --build buildOn Windows:
.\build\todo-cli.exe===== Todo CLI =====
1. Add task
2. List tasks
3. Complete task
4. Remove task
5. Exit
Choose an option:
Tasks are automatically saved to tasks.json, allowing them to persist between program executions.
This project was built to practice:
- Modern C++ fundamentals
- Classes and object-oriented design
- Header/source separation
- Encapsulation
- References and
constcorrectness - STL containers
- C++ file I/O
- JSON serialization and deserialization
- Error handling
- CMake project configuration
- Separation of responsibilities
- Basic persistence architecture
Possible future improvements include:
- Automated unit tests
- More robust JSON validation
- Better error handling and recovery
- Command-line arguments
- Task priorities and due dates
- Filtering and searching
- Improved project architecture
This project is for educational and portfolio purposes.