Build a Simple CLI Task Manager in Python ๐Ÿš€!!

Managing your daily tasks right from the terminal is super handy. Today, Iโ€™ll show you how to build a simple Command Line Interface (CLI) Task Manager in Python โ€” no fancy UI, just pure productivity!

Why Build a CLI Task Manager?
Quick to use from you…


This content originally appeared on DEV Community and was authored by Nishkarsh Pandey

Managing your daily tasks right from the terminal is super handy. Today, Iโ€™ll show you how to build a simple Command Line Interface (CLI) Task Manager in Python โ€” no fancy UI, just pure productivity!

Why Build a CLI Task Manager?
Quick to use from your terminal or SSH session.
Lightweight, no distractions.
Perfect for learning Python scripting and file handling.
Easily extendable as you grow your skills.

Features Weโ€™ll Build:

Add new tasks.
View all tasks.
Mark tasks as completed.
Delete tasks.
Save tasks persistently in a file (tasks.txt).

The Code:

import os
TASKS_FILE = "tasks.txt"
def load_tasks():
    if not os.path.exists(TASKS_FILE):
        return []
    with open(TASKS_FILE, "r") as f:
        tasks = [line.strip() for line in f.readlines()]
    return tasks

def save_tasks(tasks):
    with open(TASKS_FILE, "w") as f:
        for task in tasks:
            f.write(task + "\n")

def show_tasks(tasks):
    if not tasks:
        print("No tasks found. Time to chill! ๐Ÿ˜Ž")
    else:
        for idx, task in enumerate(tasks, 1):
            status = "[x]" if task.startswith("[x]") else "[ ]"
            task_text = task[3:] if task.startswith("[x]") or task.startswith("[ ]") else task
            print(f"{idx}. {status} {task_text}")

def add_task(tasks):
    task = input("Enter your new task: ").strip()
    if task:
        tasks.append("[ ] " + task)
        print(f'Added task: "{task}"')
    else:
        print("Task cannot be empty!")

def complete_task(tasks):
    show_tasks(tasks)
    try:
        num = int(input("Enter the task number to mark as complete: "))
        if 1 <= num <= len(tasks):
            tasks[num-1] = "[x] " + tasks[num-1][3:]
            print("Task marked as complete!")
        else:
            print("Invalid task number.")
    except ValueError:
        print("Please enter a valid number.")

def delete_task(tasks):
    show_tasks(tasks)
    try:
        num = int(input("Enter the task number to delete: "))
        if 1 <= num <= len(tasks):
            removed = tasks.pop(num-1)
            print(f'Removed task: "{removed[3:]}"')
        else:
            print("Invalid task number.")
    except ValueError:
        print("Please enter a valid number.")

def main():
    tasks = load_tasks()
    while True:
        print("\n--- CLI Task Manager ---")
        print("1. Show Tasks")
        print("2. Add Task")
        print("3. Complete Task")
        print("4. Delete Task")
        print("5. Exit")
        choice = input("Choose an option: ")

        if choice == "1":
            show_tasks(tasks)
        elif choice == "2":
            add_task(tasks)
            save_tasks(tasks)
        elif choice == "3":
            complete_task(tasks)
            save_tasks(tasks)
        elif choice == "4":
            delete_task(tasks)
            save_tasks(tasks)
        elif choice == "5":
            print("Bye! Stay productive! ๐Ÿ‘‹")
            break
        else:
            print("Invalid option, please try again.")

if __name__ == "__main__":
    main()

Output:

Image description

How to Use
Save the script as task_manager.py
Run in terminal:

python task_manager.py

Choose options by typing the number.
Your tasks will be saved in tasks.txt automatically.

Whatโ€™s Next?

Add task deadlines and reminders.
Sort tasks by priority or date.
Sync tasks with Google Calendar or Todoist APIs.
Add colors using the termcolor or your own termstyle package!

Final Thoughts!!

Building a CLI Task Manager is a great beginner project that combines file handling, user input, and basic data management. Plus, itโ€™s actually useful!

Feel free to fork and improve it on GitHub โ€” and share your version in the comments!


This content originally appeared on DEV Community and was authored by Nishkarsh Pandey


Print Share Comment Cite Upload Translate Updates
APA

Nishkarsh Pandey | Sciencx (2025-05-23T17:26:11+00:00) Build a Simple CLI Task Manager in Python ๐Ÿš€!!. Retrieved from https://www.scien.cx/2025/05/23/build-a-simple-cli-task-manager-in-python-%f0%9f%9a%80/

MLA
" » Build a Simple CLI Task Manager in Python ๐Ÿš€!!." Nishkarsh Pandey | Sciencx - Friday May 23, 2025, https://www.scien.cx/2025/05/23/build-a-simple-cli-task-manager-in-python-%f0%9f%9a%80/
HARVARD
Nishkarsh Pandey | Sciencx Friday May 23, 2025 » Build a Simple CLI Task Manager in Python ๐Ÿš€!!., viewed ,<https://www.scien.cx/2025/05/23/build-a-simple-cli-task-manager-in-python-%f0%9f%9a%80/>
VANCOUVER
Nishkarsh Pandey | Sciencx - » Build a Simple CLI Task Manager in Python ๐Ÿš€!!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/05/23/build-a-simple-cli-task-manager-in-python-%f0%9f%9a%80/
CHICAGO
" » Build a Simple CLI Task Manager in Python ๐Ÿš€!!." Nishkarsh Pandey | Sciencx - Accessed . https://www.scien.cx/2025/05/23/build-a-simple-cli-task-manager-in-python-%f0%9f%9a%80/
IEEE
" » Build a Simple CLI Task Manager in Python ๐Ÿš€!!." Nishkarsh Pandey | Sciencx [Online]. Available: https://www.scien.cx/2025/05/23/build-a-simple-cli-task-manager-in-python-%f0%9f%9a%80/. [Accessed: ]
rf:citation
» Build a Simple CLI Task Manager in Python ๐Ÿš€!! | Nishkarsh Pandey | Sciencx | https://www.scien.cx/2025/05/23/build-a-simple-cli-task-manager-in-python-%f0%9f%9a%80/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.