Metadata-Version: 2.4
Name: blog-cli
Version: 0.2.1
Summary: Agent-friendly CLI for managing a blog. Create drafts, upload media, generate time-limited preview links.
Author: tanaka-mambinge
License: MIT
Project-URL: Repository, https://github.com/tanaka-mambinge/personal-cli
Project-URL: Issues, https://github.com/tanaka-mambinge/personal-cli/issues
Keywords: blog,cli,agent,markdown,writing
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Python: >=3.13
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.28
Requires-Dist: typer>=0.16
Provides-Extra: dev
Requires-Dist: asgi-lifespan>=2.1; extra == "dev"
Requires-Dist: fastapi>=0.115; extra == "dev"
Requires-Dist: motor>=3.7; extra == "dev"
Requires-Dist: pytest>=8.3; extra == "dev"
Requires-Dist: pytest-asyncio>=0.24; extra == "dev"
Requires-Dist: pydantic>=2.10; extra == "dev"
Requires-Dist: pydantic-settings>=2.6; extra == "dev"
Requires-Dist: pymongo>=4.9; extra == "dev"
Requires-Dist: python-multipart>=0.0.20; extra == "dev"
Requires-Dist: uvicorn>=0.49; extra == "dev"

# blog-cli

Agent-friendly CLI for managing a personal blog. Create drafts, upload media, generate time-limited preview links — all from the command line.

Designed for use by both humans and AI agents.

## Install

```bash
pip install blog-cli
```

Or via pipx/uv:

```bash
pipx install blog-cli
uv tool install blog-cli
```

For development:

```bash
git clone https://github.com/tanaka-mambinge/personal-cli
cd personal-cli
uv sync --extra dev
```

## Configure

All three are required:

```bash
export PERSONAL_SERVER_URL="<your-server-url>"
export PERSONAL_API_KEY="<your-api-key>"
export PERSONAL_SITE_URL="<your-site-url>"
```

## Usage

### Articles

```bash
# Create a draft
blog-cli article create \
  --title "My Post" \
  --description "A short summary" \
  --type blog \
  --markdown "# My Post\n\nHello."

# List published blog posts
blog-cli article list --type blog

# Show an article
blog-cli article show my-post

# Update an article
blog-cli article update my-post --title "Better Title"

# Generate a 24h preview link for a draft
blog-cli article preview my-post

# Custom TTL (1–168 hours)
blog-cli article preview my-post --ttl-hours 4

# Publish
blog-cli article publish my-post --published-by agent

# Delete (soft)
blog-cli article delete my-post

# Unarchive (restore deleted)
blog-cli article unarchive my-post
```

All commands support `--json` for machine-readable output and `--server-url` to override the server.

### Media

```bash
# Upload (name is the unique key used in markdown)
blog-cli media upload --name hero-image ./hero.jpg

# Update (replace the file, keep the name)
blog-cli media update --name hero-image ./new-hero.jpg

# Delete (soft)
blog-cli media delete --name hero-image
```

### Markdown Image References

Upload media with a name, then reference it in article markdown:

```markdown
![Hero image](hero-image)

<video controls width="100%" src="ambulance-video"></video>
```

The site resolves these to full URLs automatically.

## Testing

```bash
uv run pytest -v
```

Spins up a temp MongoDB + server via test fixtures. No external deps needed.

## Architecture

```
CLI (httpx) → FastAPI server → Motor/GridFS → MongoDB
```

- **Public endpoints** (GET) — list and read published articles, download media
- **Protected endpoints** (POST/PATCH/PUT/DELETE) — require `Authorization: Bearer <key>`

## License

MIT
