# CLI Task Manager Example

A simple command-line task manager built with the MyWork framework. Perfect for
learning GSD basics and CLI development patterns.

## 🎯 **What This Example Teaches**

- ✅ GSD project planning and execution
- ✅ CLI argument parsing with Click
- ✅ JSON data persistence
- ✅ Error handling and user feedback
- ✅ Testing CLI applications
- ✅ Clean git history with atomic commits

## 📱 **Features**

```bash

# Add tasks

python task_manager.py add "Learn MyWork framework"
python task_manager.py add "Build my first CLI app" --priority high

# List tasks

python task_manager.py list
python task_manager.py list --status pending
python task_manager.py list --priority high

# Manage tasks

python task_manager.py complete 1
python task_manager.py delete 2
python task_manager.py edit 3 --title "Updated task title"

# Search and filter

python task_manager.py search "framework"
python task_manager.py stats

```markdown

## ⚡ **Quick Start**

### **1. Copy to your projects directory:**

```bash
cd /Users/dansidanutz/Desktop/MyWork
cp -r examples/cli-task-manager projects/my-task-cli
cd projects/my-task-cli

```markdown

### **2. Install dependencies:**

```bash
pip install -r requirements.txt

```markdown

### **3. Try it out:**

```bash
python src/task_manager.py --help
python src/task_manager.py add "My first task"
python src/task_manager.py list

```markdown

### **4. Run tests:**

```bash
python -m pytest tests/ -v

```markdown

## 📊 **Example Usage**

```bash

# Add some tasks

python src/task_manager.py add "Set up development environment"
python src/task_manager.py add "Read MyWork documentation" --priority high
python src/task_manager.py add "Build first project" --due "2024-02-15"

# List all tasks

python src/task_manager.py list

# Output:

# 📋 Your Tasks:

# 1. [ ] Set up development environment (normal)

# 2. [ ] Read MyWork documentation (high) - Due: 2024-02-15

# 3. [ ] Build first project (normal) - Due: 2024-02-15

# Complete a task

python src/task_manager.py complete 1

# View statistics

python src/task_manager.py stats

# Output:

# 📊 Task Statistics:

# Total: 3 tasks

# Completed: 1 (33%)

# Pending: 2 (67%)

# High priority: 1 (33%)

```markdown

## 🏗️ **Generated by GSD**

This example was created using the MyWork GSD workflow:

### **Phase 1: Foundation & Core Commands**

- ✅ CLI argument parser with Click
- ✅ Basic data models (Task, Priority, Status)
- ✅ JSON file storage system
- ✅ Core commands: add, list, complete, delete

### **Phase 2: Enhanced Features**

- ✅ Priority levels (low, normal, high)
- ✅ Due dates and reminders
- ✅ Search and filtering
- ✅ Task editing capabilities

### **Phase 3: User Experience**

- ✅ Colorful output with rich formatting
- ✅ Input validation and error handling
- ✅ Statistics and summary views
- ✅ Help documentation

### **Phase 4: Quality & Testing**

- ✅ Comprehensive test suite
- ✅ Error handling for edge cases
- ✅ Performance optimization
- ✅ Documentation and examples

## 📁 **Project Structure**

```text
cli-task-manager/
├── .planning/                  # GSD planning documents
│   ├── PROJECT.md              # Project vision and goals
│   ├── ROADMAP.md              # Development phases
│   ├── STATE.md                # Current status
│   └── phases/                 # Detailed phase plans
├── src/
│   ├── task_manager.py         # Main CLI application
│   ├── models.py               # Task data models
│   ├── storage.py              # JSON persistence layer
│   └── utils.py                # Helper functions
├── tests/
│   ├── test_task_manager.py    # Main app tests
│   ├── test_models.py          # Model tests
│   ├── test_storage.py         # Storage tests
│   └── conftest.py             # Test configuration
├── requirements.txt            # Python dependencies
├── README.md                   # This file
└── .gitignore                  # Git ignore rules

```markdown

## 🧪 **Testing**

The example includes comprehensive tests:

```bash

# Run all tests

python -m pytest tests/ -v

# Run specific test file

python -m pytest tests/test_task_manager.py -v

# Run with coverage

python -m pytest tests/ --cov=src

# Test specific functionality

python -m pytest tests/test_models.py::test_task_creation -v

```yaml

**Test coverage includes:**

- ✅ Command argument parsing
- ✅ Task creation and validation
- ✅ Storage persistence and retrieval
- ✅ Search and filtering logic
- ✅ Error handling and edge cases
- ✅ Output formatting

## 🎨 **Key Code Patterns**

### **CLI Structure with Click**

```python
import click

@click.group()
@click.pass_context
def cli(ctx):

```text

"""Simple task manager CLI."""
ctx.ensure_object(dict)
ctx.obj['storage'] = TaskStorage()

```python
@cli.command()
@click.argument('title')
@click.option('--priority', type=click.Choice(['low', 'normal', 'high']), default='normal')
@click.option('--due', type=click.DateTime(formats=['%Y-%m-%d']))
@click.pass_context
def add(ctx, title, priority, due):

```markdown

"""Add a new task."""

# Implementation here

```

```markdown

### **Data Models with Dataclasses**

```python
from dataclasses import dataclass, asdict
from datetime import datetime
from enum import Enum

class Priority(Enum):

```python

LOW = "low"
NORMAL = "normal"
HIGH = "high"

```python
@dataclass
class Task:

```yaml

id: int
title: str
priority: Priority = Priority.NORMAL
completed: bool = False
created_at: datetime = datetime.now()
due_date: datetime = None

```markdown

```markdown

### **JSON Storage Pattern**

```python
import json
from pathlib import Path
from typing import List, Optional

class TaskStorage:

```python

def __init__(self, file_path: str = "tasks.json"):

```
self.file_path = Path(file_path)
self.ensure_file_exists()

```python

def save_tasks(self, tasks: List[Task]) -> None:

```yaml
with open(self.file_path, 'w') as f:

```

json.dump([asdict(task) for task in tasks], f, indent=2, default=str)

```text

```text

```text

```

### **Rich Output Formatting**

```python
from rich.console import Console
from rich.table import Table

def display_tasks(tasks: List[Task]) -> None:

```yaml

console = Console()
table = Table(title="📋 Your Tasks")

table.add_column("ID", justify="right", style="cyan")
table.add_column("Status", justify="center")
table.add_column("Title", style="white")
table.add_column("Priority", justify="center")

for task in tasks:

```yaml
status = "✅" if task.completed else "[ ]"
priority_color = {"high": "red", "normal": "white", "low":
"dim"}[task.priority.value]
table.add_row(str(task.id), status, task.title, task.priority.value,
style=priority_color)

```markdown

console.print(table)

```markdown

```markdown

## 🔧 **Customization Ideas**

Extend this example for your needs:

### **Add Features:**

- Task categories/projects
- Recurring tasks
- Time tracking
- Export to different formats
- Sync with external services

### **Enhance UI:**

- Interactive TUI with textual
- Progress bars for long operations
- Colored output themes
- ASCII art and animations

### **Add Integration:**

- Git hooks for automatic task creation
- Calendar integration
- Slack/Discord notifications
- Web dashboard companion

## 📚 **Related Tutorials**

- [**Tutorial 1: Your First Project

  →**](../../docs/tutorials/01-first-project.md) - Step-by-step guide to
  building
  this exact example

- [**Tutorial 2: GSD Basics →**](../../docs/tutorials/02-gsd-basics.md) -

  Advanced planning techniques

- [**CLI Reference →**](../../docs/api/mw-cli.md) - Complete MyWork CLI

  documentation

## 🤝 **Contributing**

Found a bug or want to add a feature?

1. **Create a new branch:**

   ```bash
   git checkout -b feature/my-improvement

```yaml

2. **Use GSD to plan your changes:**

   ```bash
   mw gsd add-phase  # Add your enhancement as a new phase
   mw gsd plan-phase [phase]
   mw gsd execute-phase [phase]

```markdown

3. **Submit a pull request** with your improvements!

## 📄 **License**

This example is part of the MyWork framework and follows the same license terms.

---

*💡 More examples are planned. For now, focus on mastering this CLI flow and the
GSD tutorial series.*
