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)
- Clone the repository:
git clone <repository-url>
cd todo_cli
- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
- 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:
-
CLI Layer (
cli.py)- Handles command-line interface and user interaction
- Uses Click for command parsing
- Formats output using Rich library
-
Service Layer (
service.py)- Implements business logic
- Manages task operations
- Coordinates between CLI and storage
-
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 identifiertitle: Task titledescription: Optional task descriptionstatus: Task status (OPEN/COMPLETED)created_at: Creation timestampcompleted_at: Completion timestamp
Storage System
The storage system is designed to be extensible:
- 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
- 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
- Create a new class implementing the
Storageinterface:
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
- Register the backend in
config.py:
from todo_cli.config import StorageConfig
StorageConfig.register_backend("custom", MyCustomStorage)
Adding New Commands
- 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
- 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 errorsValueError: For validation errors- Custom exceptions can be added for specific cases
Testing
To run tests:
python -m pytest tests/
When adding new features:
- Write unit tests for new components
- Ensure existing tests pass
- Update documentation as needed
Contributing
- Fork the repository
- Create a feature branch
- Implement changes with tests
- Submit a pull request
Please follow the existing code style and include appropriate documentation updates.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed036a13ac54287286c07d5f4ba15d18c4d49147e106d6524277a0b9fa6b72cc
|
|
| MD5 |
63acbea77de00cbc19672c6914c0039b
|
|
| BLAKE2b-256 |
0227b4ed0adcc9e0bcad430f774b457b869e19125a072a992724db53fa5b3dc3
|
File details
Details for the file todo_cli_crazychief-0.1.0-py3-none-any.whl.
File metadata
- Download URL: todo_cli_crazychief-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3+
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ba89c630a13710824e4ed9bcb6a38e85005c575c2483a3c3e90de0f7ee1fe6a
|
|
| MD5 |
6753a337d604d2b0d9c66ff601997155
|
|
| BLAKE2b-256 |
ce8eacfbc8511ae4571029372a79ddc0e4f7e1c125f6c328f13c7405c49cf560
|