pub mod bulk_estimated;
pub mod cli;
pub mod cmd;
pub mod config;
pub mod donation_details;
pub mod eventref;
pub mod optimize_attest;
pub mod render;
pub mod session;
pub mod tax_profile;
pub use cli::Cli;
pub use config::CliConfig;
pub use session::{
BulkFilter, BulkIncomeFilter, BulkIncomePlan, BulkIncomeRow, BulkLinkPlan, BulkLinkRow,
BulkReclassifyOutflowPlan, BulkReclassifyOutflowRow, BulkResolvePlan, BulkResolveRow,
BulkStiFilter, BulkStiPlan, BulkStiRow, BulkVoidPlan, BulkVoidRow, Frame, MatchAction,
MatchProposal, Session,
};
#[derive(Debug, thiserror::Error)]
pub enum CliError {
#[error(transparent)]
Store(#[from] btctax_store::StoreError),
#[error(transparent)]
Core(#[from] btctax_core::CoreError),
#[error(transparent)]
Adapter(#[from] btctax_adapters::AdapterError),
#[error("sqlite: {0}")]
Sqlite(#[from] rusqlite::Error),
#[error("csv: {0}")]
Csv(#[from] csv::Error),
#[error("io: {0}")]
Io(#[from] std::io::Error),
#[error("not a valid event reference: {0:?}")]
BadEventRef(String),
#[error("usage: {0}")]
Usage(String),
#[error("unrecognized stored config value: key={key:?} value={value:?}")]
BadConfigValue { key: String, value: String },
#[error(
"export refused: the ledger is pseudo-reconciled (a synthetic default contributes to the \
projection). To export this draft ON PURPOSE, attest the exact phrase {:?} (pass --attest, or \
type it at the prompt). Otherwise run `reconcile pseudo off` (or approve + attest the defaults).",
ATTEST_PHRASE
)]
AttestationRequired,
#[error(
"export refused: the attestation phrase did not match. The ledger is pseudo-reconciled; type the \
phrase EXACTLY (trimmed, case-sensitive): {:?}.",
ATTEST_PHRASE
)]
AttestationFailed,
}
pub const ATTEST_PHRASE: &str = "I attest this is true";
pub fn require_attestation(attest: Option<&str>) -> Result<(), CliError> {
match attest.map(str::trim) {
Some(p) if p == ATTEST_PHRASE => Ok(()),
Some(_) => Err(CliError::AttestationFailed),
None => Err(CliError::AttestationRequired),
}
}