[package]
name = "drizzle-cli"
version.workspace = true
edition.workspace = true
authors.workspace = true
description = "Command-line interface for drizzle-rs migrations"
license.workspace = true
repository.workspace = true
rust-version.workspace = true

[[bin]]
name = "drizzle"
path = "src/main.rs"

# cargo-binstall: download the prebuilt binary from a GitHub release instead
# of building from source. URL template matches the artifacts produced by
# `.github/workflows/release.yml`:
#   v{ version }/drizzle-{ target }{ archive-suffix }
[package.metadata.binstall]
pkg-url = "{ repo }/releases/download/v{ version }/drizzle-{ target }{ archive-suffix }"
pkg-fmt = "tgz"
bin-dir = "{ bin }{ binary-ext }"

[package.metadata.binstall.overrides.x86_64-pc-windows-msvc]
pkg-fmt = "zip"

[dependencies]
# Core drizzle dependencies
drizzle-migrations = { workspace = true }
drizzle-types = { workspace = true, features = ["std", "serde", "schemars", "uuid", "chrono", "time", "geo-types", "cidr", "bit-vec"] }
drizzle-seed = { workspace = true, optional = true, default-features = false }

# CLI framework
clap = { workspace = true }
colored = { workspace = true }
heck = { workspace = true }
inquire = { workspace = true }

# Configuration
toml = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }

# File discovery
glob = { workspace = true }

# Error handling
thiserror = { workspace = true }
anyhow = { workspace = true }

# Environment variables
dotenvy = "0.15"

# Driver dependencies (optional, per-driver for push/migrate/introspect)
rusqlite = { workspace = true, optional = true, features = ["bundled"] }
postgres = { workspace = true, optional = true }
tokio-postgres = { workspace = true, optional = true }
tokio = { workspace = true, optional = true, features = ["rt", "macros"] }
libsql = { workspace = true, optional = true }
turso = { workspace = true, optional = true }

# HTTP client for d1-http driver (Cloudflare REST API).
# rustls-tls avoids requiring a system openssl on Windows/macOS devs.
reqwest = { version = "0.12", optional = true, default-features = false, features = ["json", "rustls-tls"] }

[dev-dependencies]
tempfile = { workspace = true }
assert_cmd = { workspace = true }
predicates = { workspace = true }

[features]
default = []

# SQLite drivers
rusqlite = ["dep:rusqlite", "dep:drizzle-seed", "drizzle-seed/sqlite"]
libsql = ["dep:libsql", "dep:tokio", "dep:drizzle-seed", "drizzle-seed/sqlite"]
turso = ["dep:turso", "dep:libsql", "dep:tokio", "dep:drizzle-seed", "drizzle-seed/sqlite"]

# PostgreSQL drivers
postgres-sync = ["dep:postgres", "dep:drizzle-seed", "drizzle-seed/postgres"]
tokio-postgres = ["dep:tokio-postgres", "dep:tokio", "dep:drizzle-seed", "drizzle-seed/postgres"]

# Cloudflare D1 HTTP driver (CLI-only — runtime D1 uses the Worker binding via
# the main `drizzle` crate's `d1` feature, not this).
d1-http = ["dep:reqwest", "dep:tokio", "dep:drizzle-seed", "drizzle-seed/sqlite"]

# Optional PostgreSQL value-type passthroughs for seed
uuid = ["dep:drizzle-seed", "drizzle-seed/uuid"]
serde = ["dep:drizzle-seed", "drizzle-seed/serde"]
chrono = ["dep:drizzle-seed", "drizzle-seed/chrono"]
cidr = ["dep:drizzle-seed", "drizzle-seed/cidr"]
geo-types = ["dep:drizzle-seed", "drizzle-seed/geo-types"]
bit-vec = ["dep:drizzle-seed", "drizzle-seed/bit-vec"]

# Convenience bundles
sqlite-all = ["rusqlite", "libsql", "turso", "d1-http"]
postgres-all = ["postgres-sync", "tokio-postgres"]
