Skip to content

Build a CLI app to track your tasks and manage your to-do list.

Notifications You must be signed in to change notification settings

MinaMalakH/Task-Tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task Tracker CLI

A simple command-line interface (CLI) application to track and manage your tasks. Built with TypeScript and Node.js, this project helps you organize what you need to do, what you're currently working on, and what you've completed.

Features

  • ✅ Add, update, and delete tasks
  • 🔄 Mark tasks as in-progress or done
  • 📋 List all tasks or filter by status
  • 💾 Tasks stored in JSON format
  • 🚀 No external dependencies required

Requirements

  • Node.js (v14 or higher)
  • TypeScript (v4 or higher)

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/task-tracker-cli.git
cd task-tracker-cli
  1. Install dependencies (if any):
npm install
  1. Compile TypeScript to JavaScript (if using TypeScript):
npx tsc index.ts

Or if you have a build script in package.json:

npm run build

Usage

Adding a New Task

Add a new task with a description:

node index.js add "Buy groceries"

Output:

Task added successfully (ID: 1)

Updating a Task

Update the description of an existing task:

node index.js update 1 "Buy groceries and cook dinner"

Output:

Task updated successfully (ID: 1)

Deleting a Task

Delete a task by its ID:

node index.js delete 1

Output:

Task deleted successfully (ID: 1)

Marking Task Status

Mark a task as in-progress:

node index.js mark-in-progress 1

Output:

Task marked as in-progress (ID: 1)

Mark a task as done:

node index.js mark-done 1

Output:

Task marked as done (ID: 1)

Listing Tasks

List all tasks:

node index.js list

List tasks by status:

# List only completed tasks
node index.js list done

# List only pending tasks
node index.js list todo

# List only in-progress tasks
node index.js list in-progress

Example output:

[1] Buy groceries - Status: todo
[2] Write documentation - Status: in-progress
[3] Deploy application - Status: done

Task Properties

Each task contains the following properties:

Property Type Description
id number Unique identifier for the task
description string Short description of the task
status string Task status: todo, in-progress, or done
createdAt number Timestamp when the task was created
updatedAt number Timestamp when the task was last updated

Data Storage

Tasks are stored in a tasks.json file in the same directory as the script. The file is automatically created if it doesn't exist.

Example tasks.json structure:

[
  {
    "id": 1,
    "description": "Buy groceries",
    "status": "todo",
    "createdAt": 1704067200000,
    "updatedAt": 1704067200000
  },
  {
    "id": 2,
    "description": "Write documentation",
    "status": "in-progress",
    "createdAt": 1704153600000,
    "updatedAt": 1704240000000
  }
]

Error Handling

The application includes comprehensive error handling for:

  • Missing required arguments
  • Invalid task IDs
  • Non-existent tasks
  • Invalid commands

Example error messages:

# Missing description
node index.js add
Error: Please provide a task description

# Task not found
node index.js update 999 "New description"
Error: Task with ID 999 not found

# Invalid command
node index.js invalid-command
Error: Invalid command
Available commands: add, update, delete, mark-in-progress, mark-done, list

Project Structure

task-tracker-cli/
│
├── node_modules/        # Dependencies (auto-generated)
├── .gitignore          # Git ignore file
├── index.js            # Main JavaScript source file
├── index.ts            # Main TypeScript source file
├── package-lock.json   # Dependency lock file
├── package.json        # Project configuration
├── README.md           # Project documentation
└── tasks.json          # Task data storage (auto-generated)

TypeScript Configuration

If you're using TypeScript, create a tsconfig.json file in your project root:

{
  "compilerOptions": {
    "target": "ES2020",
    "module": "commonjs",
    "outDir": "./",
    "rootDir": "./",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  },
  "include": ["index.ts"],
  "exclude": ["node_modules"]
}

Package.json Setup

Create or update your package.json:

{
  "name": "task-tracker-cli",
  "version": "1.0.0",
  "description": "A simple CLI task tracker",
  "main": "index.js",
  "scripts": {
    "build": "tsc",
    "start": "node index.js"
  },
  "keywords": ["cli", "task", "tracker", "todo"],
  "author": "Your Name",
  "license": "MIT"
}

Git Ignore

Create a .gitignore file to exclude unnecessary files:

# Dependencies
node_modules/

# Task data (optional - remove this line if you want to commit tasks)
tasks.json

# Compiled output (if keeping source TS files)
# index.js

# TypeScript cache
*.tsbuildinfo

# OS files
.DS_Store
Thumbs.db

# IDE
.vscode/
.idea/

# Logs
*.log
npm-debug.log*

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Future Enhancements

Potential features for future versions:

  • Task priorities (high, medium, low)
  • Due dates for tasks
  • Task categories/tags
  • Search functionality
  • Export tasks to CSV
  • Task statistics and analytics
  • Undo last action
  • Task archiving

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Inspired by the need for a simple, lightweight task management solution
  • Built as a practical exercise in CLI development with TypeScript
  • Project idea from roadmap.sh

Contact

Your Name - @yourtwitter - your.email@example.com

Project Link: https://github.com/yourusername/task-tracker-cli


Happy Task Tracking! 📝✨

About

Build a CLI app to track your tasks and manage your to-do list.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published