|
| 1 | +# 🚀 TypeScript Task Manager CLI |
| 2 | + |
| 3 | +A fully-featured command-line task management tool built with TypeScript. This is my TypeScript learning project showcasing modern TypeScript development best practices. |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +## ✨ Features |
| 10 | + |
| 11 | +- 📝 **Task Management**: Create, edit, and delete tasks |
| 12 | +- 🏷️ **Status Tracking**: Todo, In Progress, Completed |
| 13 | +- ⏰ **Due Dates**: Set and track task deadlines |
| 14 | +- 🎨 **Interactive CLI**: Beautiful command-line interface |
| 15 | +- 📊 **Statistics**: Task completion rates and overdue alerts |
| 16 | +- 💾 **Data Persistence**: JSON file storage |
| 17 | + |
| 18 | +## 🛠️ Tech Stack |
| 19 | + |
| 20 | +- **Language**: `TypeScript 5.2+` |
| 21 | +- **Runtime**: `Node.js 16+` |
| 22 | +- **CLI Framework**: `Commander.js` |
| 23 | +- **Interactive Interface**: `Inquirer.js` |
| 24 | +- **Styling**: `Chalk` (terminal colors) |
| 25 | +- **Tools**: `ts-node`, `nodemon` |
| 26 | + |
| 27 | +## 🚀 Quick Start |
| 28 | + |
| 29 | +### Install Dependencies |
| 30 | + |
| 31 | +```bash |
| 32 | +npm install |
| 33 | +``` |
| 34 | + |
| 35 | +### Build Project |
| 36 | + |
| 37 | +```bash |
| 38 | +npm run build |
| 39 | +``` |
| 40 | + |
| 41 | +### Run Application |
| 42 | + |
| 43 | +```bash |
| 44 | +# Show help |
| 45 | +npm start -- --help |
| 46 | + |
| 47 | +# Add a task |
| 48 | +npm start -- add -t "My first task" -d "This is a task description" |
| 49 | + |
| 50 | +# List all tasks |
| 51 | +npm start -- list |
| 52 | + |
| 53 | +# Enter interactive mode |
| 54 | +npm start -- interactive |
| 55 | + |
| 56 | +# Show statistics |
| 57 | +npm start -- stats |
| 58 | +``` |
| 59 | + |
| 60 | +### Global Installation (Optional) |
| 61 | + |
| 62 | +```bash |
| 63 | +npm run link |
| 64 | +task-manager --help |
| 65 | +``` |
| 66 | + |
| 67 | +## 📖 Usage Guide |
| 68 | + |
| 69 | +### Basic Commands |
| 70 | + |
| 71 | +| Command | Description | Example | |
| 72 | +| ------------- | ---------------- | --------------------------- | |
| 73 | +| `add` | Add a new task | `add -t "Learn TypeScript"` | |
| 74 | +| `list` | List tasks | `list --status todo` | |
| 75 | +| `update` | Update a task | `update <id> -s completed` | |
| 76 | +| `delete` | Delete a task | `delete <id>` | |
| 77 | +| `stats` | Show statistics | `stats` | |
| 78 | +| `interactive` | Interactive mode | `interactive` | |
| 79 | + |
| 80 | +### Task Status |
| 81 | + |
| 82 | +- `todo` - To Do ⏳ |
| 83 | +- `in_progress` - In Progress 🔄 |
| 84 | +- `completed` - Completed ✅ |
| 85 | + |
| 86 | +### Example Operations |
| 87 | + |
| 88 | +```bash |
| 89 | +# Add task with due date |
| 90 | +npm start -- add -t "Complete project report" --due-date "2024-12-31" |
| 91 | + |
| 92 | +# Filter tasks by status |
| 93 | +npm start -- list -s completed |
| 94 | + |
| 95 | +# Update task status |
| 96 | +npm start -- update task_xyz123 -s in_progress |
| 97 | + |
| 98 | +# Interactive task update |
| 99 | +npm start -- update task_xyz123 |
| 100 | +``` |
| 101 | + |
| 102 | +## 🏗️ Project Structure |
| 103 | + |
| 104 | +``` |
| 105 | +src/ |
| 106 | +├── index.ts # Application entry point |
| 107 | +├── types/ |
| 108 | +│ └── Task.ts # Type definitions |
| 109 | +├── services/ |
| 110 | +│ └── TaskService.ts # Core business logic |
| 111 | +├── utils/ |
| 112 | +│ └── fileUtils.ts # File operation utilities |
| 113 | +└── cli/ |
| 114 | + └── commands.ts # CLI command handlers |
| 115 | +
|
| 116 | +data/ |
| 117 | +└── tasks.json # Task data file |
| 118 | +
|
| 119 | +dist/ # Compiled JavaScript files |
| 120 | +``` |
| 121 | + |
| 122 | +## 🎓 TypeScript Features Demonstrated |
| 123 | + |
| 124 | +This project showcases the following TypeScript core concepts: |
| 125 | + |
| 126 | +### Type System |
| 127 | +```typescript |
| 128 | +// Interface definition |
| 129 | +interface Task { |
| 130 | + id: string; |
| 131 | + title: string; |
| 132 | + status: TaskStatus; |
| 133 | + dueDate?: Date; |
| 134 | +} |
| 135 | + |
| 136 | +// Enums |
| 137 | +enum TaskStatus { |
| 138 | + TODO = 'todo', |
| 139 | + IN_PROGRESS = 'in_progress', |
| 140 | + COMPLETED = 'completed' |
| 141 | +} |
| 142 | +``` |
| 143 | + |
| 144 | +### Generics |
| 145 | +```typescript |
| 146 | +interface ApiResponse<T> { |
| 147 | + success: boolean; |
| 148 | + data?: T; |
| 149 | +} |
| 150 | +``` |
| 151 | + |
| 152 | +### Classes and Access Modifiers |
| 153 | +```typescript |
| 154 | +class TaskService { |
| 155 | + private tasks: Task[] = []; |
| 156 | + |
| 157 | + async createTask(input: CreateTaskInput): Promise<ApiResponse<Task>> { |
| 158 | + // Implementation logic |
| 159 | + } |
| 160 | +} |
| 161 | +``` |
| 162 | + |
| 163 | +### Advanced Features |
| 164 | +- **Optional chaining**: `task.description?.trim()` |
| 165 | +- **Nullish coalescing**: `title ?? currentTask.title` |
| 166 | +- **Spread operator**: `{...currentTask, ...updateData}` |
| 167 | +- **Type guards**: `status is TaskStatus` |
| 168 | +- **Async/await**: Modern asynchronous programming |
| 169 | + |
| 170 | +## 🧪 Development Scripts |
| 171 | + |
| 172 | +```bash |
| 173 | +npm run build # Compile TypeScript |
| 174 | +npm run dev # Development mode |
| 175 | +npm run watch # Watch mode |
| 176 | +npm run clean # Clean compiled files |
| 177 | +npm run rebuild # Clean and rebuild |
| 178 | +``` |
0 commit comments