Requirements — Menu-Driven CLI App¶
What you will build and what you need before starting.
Learning Objectives¶
- Build an interactive main menu loop using
selectandwhile - Implement subcommands that can be called directly from the CLI
- Read and write a persistent config file from a shell script
- Display colored, formatted output in the terminal
- Structure a multi-function script cleanly with a dispatcher pattern
What You Will Build¶
taskman.sh — a task manager with both an interactive menu mode and a direct CLI mode:
$ bash taskman.sh
╔══════════════════════════════╗
║ Task Manager v1.0 ║
╚══════════════════════════════╝
1) List tasks
2) Add task
3) Complete task
4) Delete task
5) Settings
6) Quit
Choice: _
And as a direct CLI:
$ bash taskman.sh add "Buy groceries" --priority high
[OK] Task added: #4 Buy groceries [high]
$ bash taskman.sh list
ID Status Priority Task
1 ✓ high Buy milk
2 ○ normal Write readme
3 ✓ low Clean desk
4 ○ high Buy groceries
Prerequisites¶
| Skill | Where to review |
|---|---|
select for menus |
Day 04 Part 2 — Loops |
read for input |
Day 03 Part 2 — User Input & Expansion |
| Arrays | Week 02 Day 02 Part 2 |
| Functions | Week 02 Day 01 Part 1 |
| Config files | 01-system-health-monitor/implementation |
| ANSI colors | Week 02 Day 01 Part 2 — Script Structure |
Data Format¶
Tasks are stored in a plain-text file, one task per line:
# taskman.db — id:status:priority:description
1:done:high:Buy milk
2:pending:normal:Write readme
3:done:low:Clean desk
Fields: id, status (pending/done), priority (low/normal/high), description
Command-Line Interface¶
taskman.sh [COMMAND] [OPTIONS]
Commands (direct CLI):
list List all tasks
add DESCRIPTION Add a new task
done ID Mark task ID as done
delete ID Delete task ID
settings Show/edit settings
Options for add:
--priority low|normal|high (default: normal)
Run without arguments for interactive menu.
Time Estimate¶
| Part | Time |
|---|---|
| Scaffold + config | 15 min |
| Data read/write | 25 min |
| list command | 20 min |
| add / done / delete | 25 min |
| Interactive menu | 20 min |
| Colors + formatting | 15 min |
| Total | ~120 min |