Metadata-Version: 2.4
Name: daro
Version: 0.1.1
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Rust
Classifier: Topic :: Office/Business :: Scheduling
Classifier: Topic :: Utilities
Requires-Dist: click>=8.0.0
Requires-Dist: rich>=13.0.0
Requires-Dist: pytest>=7.0.0 ; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0 ; extra == 'dev'
Requires-Dist: black>=23.0.0 ; extra == 'dev'
Requires-Dist: ruff>=0.1.0 ; extra == 'dev'
Requires-Dist: twine>=4.0.0 ; extra == 'dev'
Provides-Extra: dev
Summary: A CLI tool for managing personal board data with IM sync - Python bindings for daro Rust CLI
Keywords: todo,task,manager,cli,tui,rust,board,notes
Author-email: daro team <daro@manaai.cn>
License: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Changelog, https://github.com/your-org/daro/blob/main/CHANGELOG.md
Project-URL: Documentation, https://github.com/your-org/daro#readme
Project-URL: Homepage, https://github.com/your-org/daro
Project-URL: Repository, https://github.com/your-org/daro

# daro - Python Package

[![PyPI version](https://badge.fury.io/py/daro.svg)](https://badge.fury.io/py/daro)
[![Python versions](https://img.shields.io/pypi/pyversions/daro.svg)](https://pypi.org/project/daro/)

A CLI tool for managing personal board data with IM sync - Python bindings for the daro Rust CLI.

## Features

- **Hybrid CLI**: Automatically uses Rust daro binary if installed, falls back to Python implementation
- **Full Rust API Access**: All core daro functionality available in Python via maturin bindings
- **CLI Commands**: Complete CLI interface matching the Rust daro commands
- **TUI Interface**: Direct access to the full-featured Rust TUI with real-time IM sync
- **Type Safety**: Strongly-typed Python bindings using PyO3

## How It Works

The `daro` Python CLI uses a smart hybrid approach:

1. **Rust Binary Preferred**: When you run `daro` command, it first checks if the Rust daro binary is installed on your system
2. **Seamless Delegation**: If Rust daro is found, all commands are delegated to it for maximum performance and features
3. **Python Fallback**: If Rust daro is not available, it falls back to the Python implementation using Rust bindings
4. **Check Status**: Run `daro doctor` to see which implementation is being used

```bash
$ daro doctor
Daro CLI
========

Version: 0.1.0
Build time: 2026-03-28T09:36:33.389017+00:00

Rust version: 1.91.0
Platform: macos aarch64
Config directory: /Users/jintian/.config/daro
```

## Installation

### Prerequisites

1. **Rust toolchain** (for building from source):
   ```bash
   curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
   ```

2. **Python 3.8+**

3. **maturin** (for building):
   ```bash
   pip install maturin
   ```

### Install from PyPI (recommended)

```bash
pip install daro
```

### Install from source

```bash
# Clone the repository
cd daro-py

# Install with maturin
maturin develop --release

# Or build and install
maturin build --release
pip install target/wheels/daro-*.whl
```

## Usage

### CLI Commands

```bash
# Check version
daro --version

# Login
daro login -u your_username

# Check login status
daro status

# Logout
daro logout

# Add a new board item
daro add -T "My Todo" -c "Description" -y Todo

# Add interactively
daro add -i

# List items
daro list
daro list -t Todo --page 1
daro list -s "search term"

# Edit an item
daro edit <id> -T "New Title" -c "New content"

# Delete an item
daro delete <id>

# Show statistics
daro stats

# Run TUI (full Rust TUI experience)
daro tui
```

### Python API

```python
from daro import DaroDb, DaroAuth, PyBoardDataType, PyBoardDataStatus

# Authentication
auth = DaroAuth()

# Login
user = auth.login("username", "password")
print(f"Logged in as: {user.user_nick_name}")

# Check login status
if auth.is_logged_in():
    print(f"Username: {auth.get_username()}")

# Database operations
db = DaroDb()  # Uses default path ~/.config/daro/daro.db

# Create a board item
item = db.create_board(
    title="My Task",
    content="Task description",
    board_type=PyBoardDataType.Todo,
)
print(f"Created: {item.id}")

# Get a board item
item = db.get_board(item.id)
print(f"Title: {item.title}")
print(f"Type: {item.type.label()}")  # Chinese label: 待办

# Update a board item
updated = db.update_board(
    id=item.id,
    title="Updated Title",
    status=PyBoardDataStatus.Done,
)

# List board items
items = db.list_boards(page=0, per_page=20)
for item in items:
    print(f"{item.title} - {item.status}")

# Filter by type
todos = db.list_boards(page=0, per_page=20, board_type=PyBoardDataType.Todo)

# Search
results = db.search_boards("keyword")

# Get statistics
stats = db.get_stats()
print(f"Total: {stats['total']}")
print(f"By type: {stats['by_type']}")
print(f"By status: {stats['by_status']}")

# Delete a board item
db.delete_board(item.id)

# Logout
auth.logout()
```

### Board Data Types

```python
from daro import PyBoardDataType

# All available types
PyBoardDataType.Todo       # 待办
PyBoardDataType.Thought    # 思考
PyBoardDataType.Note       # 笔记
PyBoardDataType.Diary      # 日记
PyBoardDataType.Clip       # 碎碎念
PyBoardDataType.Image      # 图片
PyBoardDataType.Link       # 链接
PyBoardDataType.Word       # 单词
PyBoardDataType.Video      # 视频
PyBoardDataType.Audio      # 声音
PyBoardDataType.Prompt     # 提示词
PyBoardDataType.Feed       # Feed流
PyBoardDataType.Book       # 书籍
PyBoardDataType.Paper      # 论文
PyBoardDataType.Transaction # 记账
PyBoardDataType.Quote      # 慧语
PyBoardDataType.Group      # 分组
PyBoardDataType.Other      # 其他
```

### Board Data Status

```python
from daro import PyBoardDataStatus

PyBoardDataStatus.Todo
PyBoardDataStatus.Doing
PyBoardDataStatus.Done
PyBoardDataStatus.Archived
```

## TUI Mode

The `daro tui` command launches the full Rust TUI with all features:

- **Real-time IM sync** with memox messages
- **Keyboard shortcuts**:
  - `n` - Create new item
  - `e` - Edit selected item
  - `d` - Delete selected item
  - `Tab` - Switch focus
  - `Enter` - Toggle preview
  - `s` - Cycle view mode
  - `h` - Show help
  - `q` - Quit
- **Content-only editing mode** (`i` key)
- **Settings popup** (`Shift+S`)
- **Preview panel** (`p` key)

## Configuration

Configuration is stored at `~/.config/daro/config.toml`:

```toml
api_url = "http://ark.manaai.cn/api/v1"
im_broker_url = "ark.manaai.cn"
mqtt_port = 1883
base_url = "https://ark.manaai.cn"
database = { path = "daro.db" }
```

Credentials are encrypted and stored at `~/.config/daro/credential`.

## Development

```bash
# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black daro/
ruff check daro/

# Build wheel
maturin build --release

# Test installation
pip install target/wheels/daro-*.whl
```

## Architecture

```
daro Python Package
├── daro._daro (Rust extension module via maturin)
│   ├── DaroDb - Database operations
│   ├── DaroAuth - Authentication
│   ├── PyBoardDataType - Type enum
│   ├── PyBoardDataStatus - Status enum
│   └── PyBoardData - Data class
├── daro.cli (Python CLI using click)
│   ├── login/logout/status
│   ├── add/edit/delete/list
│   ├── stats
│   └── tui (calls Rust TUI)
└── daro.tui (Python wrapper)
    └── Invokes Rust daro tui command
```

## License

MIT License

## Contributing

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

## Support

For issues and feature requests, please use the GitHub issue tracker.

