A small command-line task tracker built with .NET 11, System.CommandLine and
ErrorOr. Tasks are persisted in a
local JSON file.
- Add tasks with an auto-generated ID.
- List all tasks or filter by
todo,in-progress,doneornot-done. - Update a task description.
- Delete a task.
- Mark tasks as in progress or done.
- Friendly validation, not-found, usage and corrupted-JSON errors.
- Layered design with a railway-oriented application API.
- Unit and integration test suites.
- .NET 11 SDK or later.
dotnet restore todo-cli.slnx
dotnet build todo-cli.slnxRun from source:
dotnet run --project src/TaskTracker.Cli -- add "Buy groceries"Run the built executable:
dotnet src/TaskTracker.Cli/bin/Debug/net11.0/task-cli.dll helpFramework-dependent publish:
dotnet publish src/TaskTracker.Cli/TaskTracker.Cli.csproj -c Release -o publish
./publish/task-cli helpSelf-contained single-file publish (Linux x64 example):
dotnet publish src/TaskTracker.Cli/TaskTracker.Cli.csproj \
-c Release \
-r linux-x64 \
--self-contained true \
-p:PublishSingleFile=true \
-o publish/linux-x64
./publish/linux-x64/task-cli helpThe published executable is named task-cli.
Usage:
task-cli add <description>
task-cli list [todo|in-progress|done|not-done]
task-cli update <id> <description>
task-cli delete <id>
task-cli mark-in-progress <id>
task-cli mark-done <id>
task-cli help
task-cli add "Buy groceries"
# Task added successfully (ID: 1).
task-cli add "Walk the dog"
# Task added successfully (ID: 2).
task-cli list
# ID STATUS CREATED (UTC) UPDATED (UTC) DESCRIPTION
# -- ----------- ------------------- ------------------- -------------
# 1 todo 2026-01-01 12:00:00 2026-01-01 12:00:00 Buy groceries
# 2 todo 2026-01-01 12:01:00 2026-01-01 12:01:00 Walk the dog
task-cli mark-in-progress 1
# Task 1 marked as in-progress.
task-cli mark-done 2
# Task 2 marked as done.
task-cli list done
# ID STATUS CREATED (UTC) UPDATED (UTC) DESCRIPTION
# -- ------ ------------------- ------------------- ------------
# 2 done 2026-01-01 12:01:00 2026-01-01 12:02:00 Walk the dog
task-cli list not-done
# Lists every task whose status is not done.
task-cli update 1 "Buy groceries and cook dinner"
# Task 1 updated.
task-cli delete 2
# Task 2 deleted.task-cli --help
task-cli add --help
task-cli --versionBy default the CLI reads and writes tasks.json in the current working
directory. Override the path with TASKTRACKER_DATA_FILE:
TASKTRACKER_DATA_FILE=~/task-tracker/tasks.json task-cli listA missing or empty file is treated as an empty task list. The file is created
automatically the first time the CLI accesses it, including a list command.
Example:
[
{
"id": 1,
"description": "Buy groceries",
"status": "in-progress",
"createdAt": "2026-01-01T12:00:00Z",
"updatedAt": "2026-01-01T12:05:00Z"
}
]Malformed JSON produces a storage error and does not overwrite the file.
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Validation, not-found or storage failure |
2 |
Invalid usage, such as an unknown status filter |
Command-line parse errors (missing arguments, unknown commands, non-numeric IDs)
are reported by System.CommandLine with a non-zero exit code and usage text.
Error codes use dot-separated segments so each failure is identifiable.
| Code | Type | Meaning |
|---|---|---|
task.description.empty |
Validation | Task description is empty |
task.id.invalid |
Validation | Task ID is not positive |
task.not_found |
NotFound | Task does not exist |
task.id.duplicate |
Conflict | A task with the same ID already exists |
usage.status.invalid |
Custom 400 |
Unknown list filter |
storage.json.invalid |
Custom 500 |
Tasks file contains malformed JSON |
storage.read.failed |
Custom 500 |
Tasks file could not be read |
storage.write.failed |
Custom 500 |
Tasks file could not be written |
The codebase is organised as vertical slices. Each feature owns its request handler, validation and business rule; the CLI only parses input, renders output and composes the handlers.
src/
TaskTracker.Application/ Business logic
Features/
AddTask/AddTaskHandler Create a task
ListTasks/ListTasksHandler List and filter tasks
UpdateTask/UpdateTaskHandler Update a task description
DeleteTask/DeleteTaskHandler Delete a task
ChangeTaskStatus/ChangeTaskStatusHandler Mark in-progress / done
Shared/ TaskItem, status, filter, repository contract
Infrastructure/JsonTaskRepository JSON persistence adapter
TaskTracker.Cli/ Presentation only
Commands/TaskCommandHandlers Calls slices, formats output and exit codes
Commands/TaskFilterParser Parses CLI filter names
Program.cs Startup and dependency wiring
TaskCli.cs System.CommandLine command tree
tests/
TaskTracker.Application.Unit.Tests/ One test class per feature handler
TaskTracker.Cli.Tests/
TaskTracker.IntegrationTests/
| Concern | Location |
|---|---|
| Parse commands and read arguments | TaskTracker.Cli with System.CommandLine |
| Show help and display tasks/errors | TaskTracker.Cli |
| Validate description and IDs | Each application feature handler |
| Generate task IDs | AddTaskHandler |
| Create, list, update, delete and change status | Feature slices under Feature*/ |
| Define repository interface and models | TaskTracker.Application/Features/Shared |
| Serialize/deserialize JSON | TaskTracker.Application/Infrastructure/JsonTaskRepository |
| Wire dependencies at startup | TaskTracker.Cli/Program.cs |
Slice handlers return ErrorOr<T> instead of throwing for expected failures.
The CLI uses Then/Match to compose and render those results, while unexpected
failures are still surfaced as exceptions at the process boundary.
dotnet test todo-cli.slnxTest suites:
- Application unit tests are grouped by feature slice and cover add, list, update, delete and status changes, including validation, ID generation and error propagation.
- CLI unit tests cover command parsing and routing, output formatting, status parsing and exit codes.
- Integration tests cover the JSON repository (including empty and malformed files), persistence across handler restarts and full CLI workflows.