Skip to main content

A command-line TODO list application

Project description

TODO CLI Technical Documentation

Table of Contents

User Guide

Installation

You can install the TODO CLI application using one of the following methods:

Method 1: Install from PyPI (Recommended for Users)

pip install todo-cli

Method 2: Install from Source (Recommended for Developers)

  1. Clone the repository:
git clone <repository-url>
cd todo_cli
  1. Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install in development mode:
pip install -e .

This will install all required dependencies and the CLI tool. The -e flag installs the package in "editable" mode, which is useful for development.

System Requirements

  • Python 3.6 or higher
  • pip package manager

Verifying Installation

After installation, verify that the CLI tool is available:

todo --help

You should see the help message with available commands.

Configuration

The TODO CLI application can be configured using environment variables:

  • TODO_STORAGE_TYPE: Type of storage backend to use (default: 'json')
  • TODO_STORAGE_PATH: Path to the storage file/directory (default: '~/.todo/tasks.json')

Example:

export TODO_STORAGE_PATH="/custom/path/tasks.json"

Usage

Adding Tasks

todo add "Complete documentation" -d "Write user and developer guides"

Listing Tasks

todo list

Completing Tasks

todo complete <task-id>

Deleting Tasks

todo delete <task-id>

Developer Guide

Architecture

The application follows a layered architecture pattern:

  1. CLI Layer (cli.py)

    • Handles command-line interface and user interaction
    • Uses Click for command parsing
    • Formats output using Rich library
  2. Service Layer (service.py)

    • Implements business logic
    • Manages task operations
    • Coordinates between CLI and storage
  3. Storage Layer (storage.py)

    • Handles data persistence
    • Provides abstract interface for storage backends
    • Includes JSON file implementation

Project Structure

todo_cli/
├── todo_cli/
│   ├── __init__.py
│   ├── cli.py        # Command-line interface
│   ├── config.py     # Configuration management
│   ├── models.py     # Data models
│   ├── service.py    # Business logic
│   └── storage.py    # Storage implementations
├── requirements.txt
└── docs/
    └── README.md

Core Components

Models

The Task model (models.py) represents a todo item with the following attributes:

  • id: Unique identifier
  • title: Task title
  • description: Optional task description
  • status: Task status (OPEN/COMPLETED)
  • created_at: Creation timestamp
  • completed_at: Completion timestamp

Storage System

The storage system is designed to be extensible:

  1. Abstract Base Class (Storage):
class Storage(ABC):
    @abstractmethod
    def add_task(self, task: Task) -> None: pass
    @abstractmethod
    def get_task(self, task_id: str) -> Optional[Task]: pass
    @abstractmethod
    def list_tasks(self) -> List[Task]: pass
    @abstractmethod
    def update_task(self, task: Task) -> None: pass
    @abstractmethod
    def delete_task(self, task_id: str) -> None: pass
  1. JSON File Implementation (JsonFileStorage):
  • Stores tasks in a JSON file
  • Handles file creation and data serialization
  • Thread-safe file operations

Extending the Application

Adding a New Storage Backend

  1. Create a new class implementing the Storage interface:
from todo_cli.storage import Storage

class MyCustomStorage(Storage):
    def __init__(self, connection_string: str):
        # Initialize your storage
        pass

    def add_task(self, task: Task) -> None:
        # Implement task creation
        pass

    # Implement other required methods
  1. Register the backend in config.py:
from todo_cli.config import StorageConfig
StorageConfig.register_backend("custom", MyCustomStorage)

Adding New Commands

  1. Add a new command in cli.py:
@cli.command()
@click.argument("arg_name")
@click.option("--option-name", help="Option description")
def new_command(arg_name: str, option_name: str):
    """Command description."""
    service = get_service()
    # Implement command logic
  1. Add corresponding service method in service.py:
def new_service_method(self, param: str) -> Result:
    # Implement service logic
    pass

Error Handling

The application uses standard Python exceptions for error handling:

  • KeyError: For not found errors
  • ValueError: For validation errors
  • Custom exceptions can be added for specific cases

Testing

To run tests:

python -m pytest tests/

When adding new features:

  1. Write unit tests for new components
  2. Ensure existing tests pass
  3. Update documentation as needed

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Implement changes with tests
  4. Submit a pull request

Please follow the existing code style and include appropriate documentation updates.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

todo_cli_crazychief-0.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

todo_cli_crazychief-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file todo_cli_crazychief-0.1.0.tar.gz.

File metadata

  • Download URL: todo_cli_crazychief-0.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3+

File hashes

Hashes for todo_cli_crazychief-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ed036a13ac54287286c07d5f4ba15d18c4d49147e106d6524277a0b9fa6b72cc
MD5 63acbea77de00cbc19672c6914c0039b
BLAKE2b-256 0227b4ed0adcc9e0bcad430f774b457b869e19125a072a992724db53fa5b3dc3

See more details on using hashes here.

File details

Details for the file todo_cli_crazychief-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for todo_cli_crazychief-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ba89c630a13710824e4ed9bcb6a38e85005c575c2483a3c3e90de0f7ee1fe6a
MD5 6753a337d604d2b0d9c66ff601997155
BLAKE2b-256 ce8eacfbc8511ae4571029372a79ddc0e4f7e1c125f6c328f13c7405c49cf560

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page