Skip to main content

btctax_cli/
lib.rs

1//! btctax-cli: the CLI + reconciliation library that wires the encrypted vault (btctax-store),
2//! ingest (btctax-adapters), and the pure projection (btctax-core) into the Phase-1 command surface
3//! (spec §11). The library is I/O-explicit and deterministic; the binary (`main.rs`) is a thin clap
4//! dispatch. PRIVACY: tests use only temp vaults + synthetic fixtures; no real user file is ever read.
5pub mod bulk_estimated;
6pub mod cli;
7pub mod cmd;
8pub mod config;
9pub mod donation_details;
10pub mod eventref;
11pub mod optimize_attest;
12pub mod render;
13pub mod session;
14pub mod tax_profile;
15
16pub use cli::Cli;
17pub use config::CliConfig;
18pub use session::{
19    BulkFilter, BulkIncomeFilter, BulkIncomePlan, BulkIncomeRow, BulkLinkPlan, BulkLinkRow,
20    BulkReclassifyOutflowPlan, BulkReclassifyOutflowRow, BulkResolvePlan, BulkResolveRow,
21    BulkStiFilter, BulkStiPlan, BulkStiRow, BulkVoidPlan, BulkVoidRow, Frame, MatchAction,
22    MatchProposal, Session,
23};
24
25#[derive(Debug, thiserror::Error)]
26pub enum CliError {
27    #[error(transparent)]
28    Store(#[from] btctax_store::StoreError),
29    #[error(transparent)]
30    Core(#[from] btctax_core::CoreError),
31    #[error(transparent)]
32    Adapter(#[from] btctax_adapters::AdapterError),
33    #[error("sqlite: {0}")]
34    Sqlite(#[from] rusqlite::Error),
35    /// C1: `write_csv_exports` (Task 15) uses `?` on `csv::Writer` ops (→ `csv::Error`); `csv::Error`
36    /// is its own type (NOT covered by `Io(#[from] io::Error)`, whose `From` goes the other way), so it
37    /// needs its own variant or Task 15 will not compile.
38    #[error("csv: {0}")]
39    Csv(#[from] csv::Error),
40    #[error("io: {0}")]
41    Io(#[from] std::io::Error),
42    /// A user-supplied event reference did not parse as a canonical `EventId` (eventref.rs).
43    #[error("not a valid event reference: {0:?}")]
44    BadEventRef(String),
45    /// A CLI argument was malformed (bad USD/date/enum/wallet spec, or a contradictory flag set).
46    #[error("usage: {0}")]
47    Usage(String),
48    /// M1: a `cli_config` row held an unrecognized value (corrupt DB, future-written value, or manual
49    /// edit gone wrong). Returning an error is safer than silently misreading the stored intent.
50    #[error("unrecognized stored config value: key={key:?} value={value:?}")]
51    BadConfigValue { key: String, value: String },
52}