Skip to content

A TypeScript CLI task management tool - Learning project

Notifications You must be signed in to change notification settings

andylinee/task-manager-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 TypeScript Task Manager CLI

A fully-featured command-line task management tool built with TypeScript. This is my TypeScript learning project showcasing modern TypeScript development best practices.

TypeScript Node.js CLI

✨ Features

  • 📝 Task Management: Create, edit, and delete tasks
  • 🏷️ Status Tracking: Todo, In Progress, Completed
  • Due Dates: Set and track task deadlines
  • 🎨 Interactive CLI: Beautiful command-line interface
  • 📊 Statistics: Task completion rates and overdue alerts
  • 💾 Data Persistence: JSON file storage

🛠️ Tech Stack

  • Language: TypeScript 5.2+
  • Runtime: Node.js 16+
  • CLI Framework: Commander.js
  • Interactive Interface: Inquirer.js
  • Styling: Chalk (terminal colors)
  • Tools: ts-node, nodemon

🚀 Quick Start

Install Dependencies

npm install

Build Project

npm run build

Run Application

# Show help
npm start -- --help

# Add a task
npm start -- add -t "My first task" -d "This is a task description"

# List all tasks
npm start -- list

# Enter interactive mode
npm start -- interactive

# Show statistics
npm start -- stats

Global Installation (Optional)

npm run link
task-manager --help

📖 Usage Guide

Basic Commands

Command Description Example
add Add a new task add -t "Learn TypeScript"
list List tasks list --status todo
update Update a task update <id> -s completed
delete Delete a task delete <id>
stats Show statistics stats
interactive Interactive mode interactive

Task Status

  • todo - To Do ⏳
  • in_progress - In Progress 🔄
  • completed - Completed ✅

Example Operations

# Add task with due date
npm start -- add -t "Complete project report" --due-date "2024-12-31"

# Filter tasks by status
npm start -- list -s completed

# Update task status
npm start -- update task_xyz123 -s in_progress

# Interactive task update
npm start -- update task_xyz123

🏗️ Project Structure

src/
├── index.ts              # Application entry point
├── types/
│   └── Task.ts          # Type definitions
├── services/
│   └── TaskService.ts   # Core business logic
├── utils/
│   └── fileUtils.ts     # File operation utilities
└── cli/
    └── commands.ts      # CLI command handlers

data/
└── tasks.json          # Task data file

dist/                   # Compiled JavaScript files

🎓 TypeScript Features Demonstrated

This project showcases the following TypeScript core concepts:

Type System

// Interface definition
interface Task {
  id: string;
  title: string;
  status: TaskStatus;
  dueDate?: Date;
}

// Enums
enum TaskStatus {
  TODO = 'todo',
  IN_PROGRESS = 'in_progress',
  COMPLETED = 'completed'
}

Generics

interface ApiResponse<T> {
  success: boolean;
  data?: T;
}

Classes and Access Modifiers

class TaskService {
  private tasks: Task[] = [];
  
  async createTask(input: CreateTaskInput): Promise<ApiResponse<Task>> {
    // Implementation logic
  }
}

Advanced Features

  • Optional chaining: task.description?.trim()
  • Nullish coalescing: title ?? currentTask.title
  • Spread operator: {...currentTask, ...updateData}
  • Type guards: status is TaskStatus
  • Async/await: Modern asynchronous programming

🧪 Development Scripts

npm run build     # Compile TypeScript
npm run dev       # Development mode
npm run watch     # Watch mode
npm run clean     # Clean compiled files
npm run rebuild   # Clean and rebuild