[workspace]
members = [".", "xtask"]
# `fuzz/` is a standalone cargo-fuzz package built with nightly + sanitizers
# via its own toolchain. It must not share the workspace's resolver/lockfile.
exclude = ["fuzz"]
resolver = "3"

[package]
name = "bzr"
version = "0.4.4"
edition = "2021"
description = "A CLI for Bugzilla, inspired by gh"
license = "MIT"
rust-version = "1.89"
repository = "https://github.com/randomparity/bzr"
homepage = "https://github.com/randomparity/bzr"
keywords = ["bugzilla", "cli", "bug-tracker"]
categories = ["command-line-utilities"]

[features]
# OS keychain-backed API key storage (macOS Keychain, Windows Credential
# Manager, Linux Secret Service). Enabled by default; disable with
# --no-default-features to omit platform keyring backends.
default = ["keyring"]
keyring = [
    "dep:apple-native-keyring-store",
    "dep:dbus-secret-service-keyring-store",
    "dep:keyring-core",
    "dep:rpassword",
    "dep:windows-native-keyring-store",
]
# Statically link libdbus into the binary so it carries no runtime
# libdbus-1.so dependency. Off by default (local Linux builds keep using the
# faster system libdbus). Enabled in CI only for the prebuilt x86_64/aarch64
# Linux release artifacts that feed Homebrew bottles: a bottle is poured as-is
# and, unlike the .deb/.rpm packages, cannot declare a system-library
# dependency, so the binary must be self-contained. The weak `?` keeps this a
# no-op on macOS/Windows, where the Secret Service store is not compiled.
vendored-keyring = ["dbus-secret-service-keyring-store?/vendored"]
# Exposes test helpers from the library for integration tests.
# Activated automatically via dev-dependency below.
test-helpers = ["dep:wiremock", "dep:tempfile"]

[dependencies]
base64 = "0.22"
clap = { version = ">=4.5.60, <4.7", features = ["derive"] }
reqwest = { version = "0.12", features = ["json", "rustls-tls-native-roots"], default-features = false }
rustls = { version = "0.23", default-features = false, features = ["std"] }
rustls-native-certs = "0.8"
sha2 = "0.10"
webpki-roots = "1.0"
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1", features = ["preserve_order"] }
tokio = { version = "1", features = ["macros", "rt", "sync"] }
toml = "1"
dirs = "6"
tabled = { version = "0.21", default-features = false, features = ["std"] }
thiserror = "2"
colored = "3"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
percent-encoding = "2"
url = "2"
quick-xml = "0.40"
# Optional: used only by test-helpers feature
wiremock = { version = ">=0.6, <0.6.6", optional = true }
tempfile = { version = "3", optional = true }
keyring-core = { version = "1", optional = true }
rpassword = { version = "7", optional = true }

[target.'cfg(target_os = "macos")'.dependencies]
apple-native-keyring-store = { version = "1", features = ["keychain"], optional = true }

[target.'cfg(target_os = "linux")'.dependencies]
dbus-secret-service-keyring-store = { version = "1", features = ["crypto-rust"], optional = true }

[target.'cfg(target_os = "windows")'.dependencies]
windows-native-keyring-store = { version = "1", optional = true }

[dev-dependencies]
proptest = "1"
rcgen = "0.14"
tempfile = "3"
wiremock = ">=0.6, <0.6.6"
bzr = { path = ".", features = ["test-helpers"], default-features = false }
# No-op proc-macro for `#[mutants::skip]`. Used in a few places where
# `exclude_re` in .cargo/mutants.toml cannot reach (e.g. cargo-mutants's
# `delete field` operator on struct expressions).
mutants = "0.0.4"

[[bin]]
name = "bzr_lock_helper"
path = "src/bin/bzr_lock_helper.rs"
required-features = ["test-helpers"]

[package.metadata.deb]
maintainer = "David Christensen <randomparity@gmail.com>"
copyright = "2025-2026 David Christensen <randomparity@gmail.com>"
license-file = ["LICENSE", "0"]
extended-description = """
bzr is a Bugzilla CLI inspired by GitHub's gh, supporting both REST and
XML-RPC APIs, multi-server configuration, saved queries and templates,
and OS-keychain-backed credential storage."""
section = "devel"
priority = "optional"
# Explicit dependencies. We do not use cargo-deb's `$auto` because the binary
# is cross-compiled in CI and ldd-based introspection would scan the wrong
# architecture.
depends = "libc6, libdbus-1-3"
recommends = "ca-certificates"
assets = [
    ["target/release/bzr",                     "usr/bin/",                          "755"],
    ["man/man1/bzr.1",                         "usr/share/man/man1/",               "644"],
    ["man/man1/bzr-*.1",                       "usr/share/man/man1/",               "644"],
    ["README.md",                              "usr/share/doc/bzr/README.md",       "644"],
    ["CHANGELOG.md",                           "usr/share/doc/bzr/CHANGELOG.md",    "644"],
]

[package.metadata.generate-rpm]
summary = "A CLI for Bugzilla, inspired by gh"
# Disable rpm-build's automatic Requires extraction. It runs `ldd` on the host
# which produces wrong results for cross-compiled binaries; declare deps
# explicitly below instead.
auto-req = "no"
[package.metadata.generate-rpm.requires]
glibc = "*"
dbus-libs = "*"
[[package.metadata.generate-rpm.assets]]
source = "target/release/bzr"
dest = "/usr/bin/bzr"
mode = "755"
[[package.metadata.generate-rpm.assets]]
source = "man/man1/bzr.1"
dest = "/usr/share/man/man1/bzr.1"
mode = "644"
doc = true
[[package.metadata.generate-rpm.assets]]
source = "man/man1/bzr-*.1"
dest = "/usr/share/man/man1/"
mode = "644"
doc = true
[[package.metadata.generate-rpm.assets]]
source = "README.md"
dest = "/usr/share/doc/bzr/README.md"
mode = "644"
doc = true
[[package.metadata.generate-rpm.assets]]
source = "CHANGELOG.md"
dest = "/usr/share/doc/bzr/CHANGELOG.md"
mode = "644"
doc = true
[[package.metadata.generate-rpm.assets]]
source = "LICENSE"
dest = "/usr/share/licenses/bzr/LICENSE"
mode = "644"

[lints.clippy]
pedantic = { level = "warn", priority = -1 }
unwrap_used = "deny"
expect_used = "warn"
panic = "deny"
panic_in_result_fn = "deny"
unimplemented = "deny"
allow_attributes = "warn"
dbg_macro = "deny"
todo = "deny"
print_stdout = "deny"
print_stderr = "deny"
module_name_repetitions = "allow"
similar_names = "allow"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(fuzzing)"] }
