btctax_cli/cli.rs
1//! The clap-4 command surface for `btctax`, extracted into the library so tooling
2//! (the `xtask` man-page generator) can obtain the `Command` via `Cli::command()`
3//! (`clap::CommandFactory`). The binary (`main.rs`) is a thin dispatch over these types.
4//!
5//! FILE-FORMAT DOCS — SINGLE SOURCE OF TRUTH: the long-help (`///` doc-comments with
6//! `#[arg(verbatim_doc_comment)]`) on the file/format-taking args below is rendered BOTH
7//! into `--help` (clap) AND into the per-subcommand man page (clap_mangen), zero drift.
8//! Formats were read from the writers, never from stale comments: export CSVs from
9//! `render.rs`, the classify-raw serde shape from `btctax-core::EventPayload`, the key
10//! armor from `btctax-store::Vault::backup_key`, the selections header from
11//! `cmd::reconcile::import_selections`, the lot pick from `eventref::parse_lot_pick`.
12use btctax_core::{FilingStatus, LotMethod};
13use clap::{Parser, Subcommand, ValueEnum};
14use std::path::PathBuf;
15
16#[derive(Parser)]
17#[command(name = "btctax", about = "Offline US Bitcoin tax ledger (Phase 1)")]
18pub struct Cli {
19 /// Path to the encrypted vault (vault.pgp).
20 #[arg(long, global = true, default_value = "vault.pgp")]
21 pub vault: PathBuf,
22 #[command(subcommand)]
23 pub command: Command,
24}
25
26#[derive(Subcommand)]
27pub enum Command {
28 /// Create the encrypted vault + force a key backup.
29 Init {
30 /// File to write the forced key backup to: an ASCII-armored, passphrase(S2K)-encrypted
31 /// private key, owner-only (mode 0600). Identical format to `backup-key --out`. Store it
32 /// offline — it is the only way to recover the vault if you lose `vault.key`.
33 ///
34 /// FORMAT (structure — NOT a real key):
35 /// -----BEGIN PGP PRIVATE KEY BLOCK-----
36 /// ... base64 armor of the S2K-encrypted secret key ...
37 /// -----END PGP PRIVATE KEY BLOCK-----
38 #[arg(long, verbatim_doc_comment)]
39 key_backup: PathBuf,
40 /// Clear an interrupted/half-created init (orphan `vault.key`, no encrypted store) and start fresh.
41 #[arg(long, default_value_t = false)]
42 repair: bool,
43 },
44 /// Import one or more export files (auto-groups Swan).
45 Import { files: Vec<PathBuf> },
46 /// FR9 integrity check (non-zero exit on hard blockers).
47 Verify,
48 /// Show holdings + realized disposals/removals/income. With --tax-year: standalone TaxResult.
49 #[command(alias = "show")]
50 Report {
51 /// Filter realized disposals/removals/income to a specific calendar year (display path).
52 #[arg(long)]
53 year: Option<i32>,
54 /// Compute the crypto-attributable federal tax for the given tax year (B.5 / Task 9).
55 /// Requires a stored tax profile (`tax-profile --year Y ...`) and the bundled TY table.
56 /// Independent of --year; the two flags are not aliased.
57 #[arg(long)]
58 tax_year: Option<i32>,
59 /// Cumulative prior-year TAXABLE gifts (post-annual-exclusion Form 709 amounts), not
60 /// gross gifts. Used for the §2505 lifetime-exclusion consumption advisory. Defaults to
61 /// $0 when omitted (the advisory discloses this assumption). Must not be negative.
62 #[arg(long)]
63 prior_taxable_gifts: Option<String>,
64 },
65 /// Emit a reconciliation decision event.
66 #[command(subcommand)]
67 Reconcile(Reconcile),
68 /// Show or set projection config (TP8 fee treatment / pre-2025 lot method / forward method).
69 Config {
70 #[arg(long, value_enum)]
71 set_fee_treatment: Option<FeeArg>,
72 #[arg(long, value_enum)]
73 set_pre2025_method: Option<MethodLotArg>,
74 #[arg(long, default_value_t = false)]
75 attest_pre2025_method: bool,
76 /// §A.5(a): append a MethodElection decision (the forward standing order). Not a flag
77 /// mutation — this is an event in the ledger. Use --effective-from to set the date
78 /// (default: today / the decision's made-date).
79 #[arg(long, value_enum)]
80 set_forward_method: Option<MethodLotArg>,
81 /// §A.5(a) per-ACCOUNT scope for --set-forward-method (IRS 2025+ per-account rule):
82 /// exchange:PROVIDER:ACCOUNT (the canonical wallet grammar). Omit for a GLOBAL election
83 /// (the existing behavior). Only exchange accounts are electable (a method election is a
84 /// brokerage-account concept; self:LABEL is rejected). The account MUST already exist in the
85 /// vault — an unknown/typo'd account is rejected LOUDLY so it can't create a dead election.
86 #[arg(long)]
87 exchange: Option<String>,
88 /// Effective-from date for --set-forward-method (YYYY-MM-DD). Defaults to made-date.
89 #[arg(long)]
90 effective_from: Option<String>,
91 },
92 /// FR10: export decrypted SQLite + CSV (the NFR2 plaintext exception).
93 ///
94 /// WARNS (does not refuse) on unresolved Hard blockers: any Hard blocker makes every affected
95 /// tax year NOT COMPUTABLE, so the exported Form 8949 / Schedule D / figures are INFORMATIONAL,
96 /// not final. A warning is printed to stderr and the export still succeeds (exit 0). Automation
97 /// that must GATE on unresolved blockers should check `btctax verify` (which exits non-zero),
98 /// since export-snapshot itself stays exit 0.
99 ExportSnapshot {
100 /// Output DIRECTORY receiving the decrypted SQLite DB (snapshot.sqlite) + projection CSVs
101 /// (the NFR2 plaintext exception; created owner-only). ALWAYS writes: lots.csv,
102 /// disposals.csv, removals.csv, income.csv. With --tax-year it ALSO writes form8949.csv,
103 /// schedule_d.csv, form8283.csv, and schedule_se.csv (schedule_se only when there is
104 /// business self-employment income). The `event` column in disposals.csv / removals.csv /
105 /// income.csv is the event-ref that reconcile commands consume (select-lots,
106 /// set-donation-details, reclassify-income, …).
107 ///
108 /// FORMAT (removals.csv header + one sample donation row):
109 /// event,kind,removed_at,lot,sat,basis,fmv_at_transfer,term,acquired_at,claimed_deduction,donee
110 /// import|coinbase|X,donation,2025-03-01,import|coinbase|X#0,25000,120.00,150.00,long,2023-01-05,150.00,Charity Y
111 #[arg(long, verbatim_doc_comment)]
112 out: PathBuf,
113 /// Also emit the per-tax-year Form 8949 + Schedule D CSVs (form8949.csv / schedule_d.csv),
114 /// scoped to this calendar year. Omit to write only the all-years projection CSVs.
115 #[arg(long)]
116 tax_year: Option<i32>,
117 /// Attestation phrase required to export while the ledger is PSEUDO-RECONCILED (a synthetic
118 /// default contributes to the projection). Pass the exact phrase `I attest this is true`
119 /// (trimmed, case-sensitive) to export the fictional draft ON PURPOSE. Omit on a fully-real
120 /// ledger (never gated). Omit on an interactive terminal to be prompted; omit when piped
121 /// (non-TTY) while pseudo-active and the export is refused.
122 #[arg(long)]
123 attest: Option<String>,
124 },
125 /// Fill the OFFICIAL IRS fillable PDFs for a tax year (a whole packet).
126 ///
127 /// Writes (owner-only) into --out, populated from btctax's already-computed projection — no
128 /// capital-gains figure is recomputed:
129 /// - f8949.pdf + schedule_d.pdf — ALWAYS. On the 2025 (1099-DA) revision Bitcoin is filed under
130 /// Box I (short-term) / Box L (long-term) — the digital-asset boxes; on the pre-1099-DA 2024
131 /// and 2017 revisions it is Box C / Box F ("not reported on a 1099-B"). Never the wrong pair
132 /// for the year. More rows than a part's grid holds (11 in 2025, 14 in 2024/2017) paginate
133 /// onto multiple copies, each with its own totals.
134 /// - schedule_se.pdf — when there is business self-employment income and net earnings are ≥ the
135 /// $400 floor. Line 12 (SE tax) = Social Security + regular Medicare ONLY; the 0.9% Additional
136 /// Medicare Tax is a Form 8959 item (flagged on stderr, not put on Schedule SE). Requires a
137 /// stored `tax-profile` for the year (filing status); missing profile ⇒ a NOTE, not a form.
138 /// - form_8283.pdf — when there are BTC donations. Fills the donee/appraiser IDENTITY + per-
139 /// donation property rows (Section A ≤ $5,000 or Section B > $5,000). The property-type box is
140 /// "k Digital assets" on the Rev. 12-2023/2025 forms (2024/2025); the 2017 Rev. 12-2014 form
141 /// has no such box, so BTC uses "j Other" + a printed note. Leaves every OTHER party's
142 /// declaration/signature BLANK — a Section B 8283 is NOT filing-ready without those signed.
143 /// Overflows onto additional copies.
144 /// - form_1040_capgains.pdf — when there is reportable capital/digital-asset activity. Fills the
145 /// capital-gain line (line 7a in 2025 / line 7 in 2024 / line 13 in 2017, when Schedule D is
146 /// active and line 16 ≥ 0; active-and-zero → "-0-"; a net loss leaves it blank — the §1211
147 /// line-21 cap is yours) and, on 2024/2025, the Digital-Asset question (YES iff any disposal,
148 /// income, gift, or donation; never a "No"). The 2017 form has no Digital-Asset question, so an
149 /// income-only 2017 year produces no 1040. 7b checkboxes are untouched.
150 ///
151 /// Every written value is read back GEOMETRICALLY against the blank PDF's own field coordinates and
152 /// the fill FAILS CLOSED on any mis-placement — a wrong tax form is never written. The engine drops
153 /// the forms' XFA layer (else Acrobat opens them blank) and sets NeedAppearances so a viewer
154 /// regenerates the visible values. Schedule D lines 17-22 (28%-rate / unrecaptured-§1250 / QDI
155 /// worksheet, incl. the line-21 loss limit) are OUT OF SCOPE. Rows on an exchange that MAY carry
156 /// 1099-DA broker reporting are flagged on stderr (btctax files them all under Box I/L and says so).
157 ///
158 /// PSEUDO-RECONCILED ledgers: the same attestation gate as export-snapshot applies, AND every
159 /// page is stamped with a diagonal `DRAFT — ESTIMATE, NOT FOR FILING` watermark.
160 ExportIrsPdf {
161 /// Output DIRECTORY receiving the filled official PDFs (created owner-only): f8949.pdf,
162 /// schedule_d.pdf, and — when applicable — schedule_se.pdf, form_8283.pdf,
163 /// form_1040_capgains.pdf. These contain your unencrypted tax data — write --out OUTSIDE any
164 /// git repo.
165 #[arg(long, verbatim_doc_comment)]
166 out: PathBuf,
167 /// The tax year to fill (this build bundles TY2017, TY2024 and TY2025; other years are
168 /// refused). TY2024/TY2017 are pre-1099-DA revisions: Bitcoin is filed under Box C/F (not Box
169 /// I/L). TY2017 additionally uses the OLD forms — the §B long Schedule SE, Form 8283 Rev.
170 /// 12-2014 ("j Other", no digital-asset box), the 1040 capital gain on line 13, and NO
171 /// Digital-Asset question.
172 #[arg(long)]
173 tax_year: i32,
174 /// Restrict the packet to specific forms (repeat or comma-separate). Default = every
175 /// applicable form (f8949 + schedule-d always; schedule-se when SE income ≥ the $400 floor;
176 /// form-8283 when there are donations; form-1040 when there is reportable digital-asset
177 /// activity). A named form is still skipped when it does not apply.
178 #[arg(long, value_enum, value_delimiter = ',')]
179 forms: Vec<FormArg>,
180 /// Attestation phrase required to export while the ledger is PSEUDO-RECONCILED (a synthetic
181 /// default contributes to the projection). Pass the exact phrase `I attest this is true`
182 /// (trimmed, case-sensitive) to fill the DRAFT-watermarked forms ON PURPOSE. Omit on a
183 /// fully-real ledger (never gated). Omit on an interactive terminal to be prompted; omit when
184 /// piped (non-TTY) while pseudo-active and the export is refused.
185 #[arg(long)]
186 attest: Option<String>,
187 },
188 /// Export the passphrase-protected key.
189 BackupKey {
190 /// File to write the exported key to: an ASCII-armored, passphrase(S2K)-encrypted private
191 /// key, owner-only (mode 0600). Identical format to `init --key-backup`.
192 ///
193 /// FORMAT (structure — NOT a real key):
194 /// -----BEGIN PGP PRIVATE KEY BLOCK-----
195 /// ... base64 armor of the S2K-encrypted secret key ...
196 /// -----END PGP PRIVATE KEY BLOCK-----
197 #[arg(long, verbatim_doc_comment)]
198 out: PathBuf,
199 },
200 /// Lot-specific-identification optimizer (§C — read-only proposal or gated persistence).
201 #[command(subcommand)]
202 Optimize(Optimize),
203 /// Read-only what-if tax planning (task #43): posit a HYPOTHETICAL, NON-persisted transaction and
204 /// see its MARGINAL federal-tax effect on the current-year position. Routes through the same audited
205 /// tax engine as `report --tax-year`; invents no tax authority. Writes NOTHING — no event, no
206 /// side-table row, no vault mutation. Tax decision-support (consequences), not buy/sell/hold advice.
207 #[command(subcommand)]
208 WhatIf(WhatIf),
209 /// Set or show the per-tax-year tax profile (filing status, income, MAGI, etc.).
210 TaxProfile {
211 /// The tax year (e.g. 2025).
212 #[arg(long)]
213 year: i32,
214 /// IRS filing status.
215 #[arg(long, value_enum)]
216 filing_status: Option<FilingStatusArg>,
217 /// Ordinary taxable income EXCLUDING all app-computed crypto items (net ST gains,
218 /// mining/staking ordinary income). The engine adds the crypto items on top (B.1 / I5).
219 #[arg(long)]
220 ordinary_taxable_income: Option<String>,
221 /// Modified AGI excluding crypto items, for the §1411 NIIT threshold comparison.
222 ///
223 /// IMPORTANT (§1411 contract): this value MUST already include the taxpayer's qualified
224 /// dividends and non-crypto net capital gains (and any other MAGI add-backs from
225 /// §1411(d)). The engine adds ONLY the crypto AGI delta on top (ambiguity #5 in the
226 /// design). Omitting QD or non-crypto cap gains from this figure understates NIIT.
227 #[arg(
228 long,
229 long_help = "Modified AGI excluding crypto items, for the §1411 NIIT \
230 threshold comparison.\n\nIMPORTANT (§1411 contract): this value MUST already \
231 include the taxpayer's qualified dividends and non-crypto net capital gains (and \
232 any other MAGI add-backs from §1411(d)). The engine adds ONLY the crypto AGI \
233 delta on top (ambiguity #5 in the design). Omitting QD or non-crypto cap gains \
234 from this figure understates NIIT."
235 )]
236 magi_excluding_crypto: Option<String>,
237 /// Qualified dividends + other preferential-rate income sharing the §1(h) 0/15/20 LTCG
238 /// rate stack. Required when setting a profile.
239 #[arg(long)]
240 qualified_dividends: Option<String>,
241 /// Non-crypto net LT-character capital gain already in the profile (optional; defaults
242 /// to 0 when omitted).
243 #[arg(long)]
244 other_net_capital_gain: Option<String>,
245 /// §1212(b) short-term capital loss carryforward into this year (optional; defaults to 0).
246 #[arg(long)]
247 carryforward_short: Option<String>,
248 /// §1212(b) long-term capital loss carryforward into this year (optional; defaults to 0).
249 #[arg(long)]
250 carryforward_long: Option<String>,
251 /// Form W-2 Social Security wages (Box 3 + Box 7 tips; Schedule SE line 8a).
252 /// Reduces the §1401(a) SS cap: ss_cap = max(0, wage_base − w2_ss_wages). Optional;
253 /// defaults to $0. Must not be negative.
254 #[arg(long)]
255 w2_ss_wages: Option<String>,
256 /// Medicare wages (Box 5; Form 8959 line 1).
257 /// Reduces the Additional-Medicare threshold: addl_threshold = max(0, threshold − w2_medicare_wages)
258 /// (§1401(b)(2)(B)/Form 8959 Part II). Optional; defaults to $0. Must not be negative.
259 #[arg(long)]
260 w2_medicare_wages: Option<String>,
261 /// Schedule C deductible business expenses for the year — reduces net SE earnings;
262 /// the income-tax stack above is NOT adjusted (see the advisory).
263 /// Optional; defaults to $0. Must not be negative.
264 #[arg(long)]
265 schedule_c_expenses: Option<String>,
266 /// Show the stored profile for `--year` instead of setting it.
267 #[arg(long, default_value_t = false)]
268 show: bool,
269 },
270}
271
272/// `optimize` subcommand tree. Task 9 adds `Run`; Task 10 adds `Accept`; Task 11 adds `Consult`.
273#[derive(Subcommand)]
274pub enum Optimize {
275 /// Mode-1 what-if: print the tax-saving lot-selection proposal. NOTHING is filed or bound.
276 Run {
277 /// The tax year to optimize (must be 2025 or later).
278 #[arg(long)]
279 tax_year: i32,
280 },
281 /// Mode-1 gated persistence: recompute the optimum and persist the proposed LotSelection(s),
282 /// gated per disposal (§1.1012-1(j)). A genuinely-contemporaneous pick (made ≤ sale) persists
283 /// freely; an already-executed disposal persists ONLY with a narrow per-disposal `--attest`
284 /// scoped to one `--disposal`; a 2027+ broker-held pick is refused. Revoke via `reconcile void`.
285 Accept {
286 /// The tax year to accept (must be 2025 or later).
287 #[arg(long)]
288 tax_year: i32,
289 /// Restrict to ONE disposal (required to carry `--attest`).
290 #[arg(long)]
291 disposal: Option<String>,
292 /// Narrow contemporaneous-ID attestation for an already-executed disposal. Requires
293 /// `--disposal` (no blanket attestation across all disposals).
294 #[arg(long)]
295 attest: Option<String>,
296 },
297 /// Mode-2 read-only pre-trade what-if (§C.3): tax-min lots + ST/LT split + federal tax + ST→LT
298 /// timing. NOTHING is written — no event, no side-table row. Tax decision-support only;
299 /// not buy/sell/hold advice.
300 Consult {
301 /// Hypothetical sale amount (required). Accepts a satoshi integer OR a BTC decimal, e.g.
302 /// `0.05` or `5000000` (a value with a `.` is BTC; a bare integer is satoshis).
303 #[arg(long)]
304 sell: String,
305 /// Wallet to sell from, e.g. `self:cold` or `exchange:coinbase:default` (required; per-wallet
306 /// pool is mandatory post-2025).
307 #[arg(long)]
308 wallet: Option<String>,
309 /// Sale date for the what-if (YYYY-MM-DD; defaults to today UTC if omitted).
310 #[arg(long)]
311 at: Option<String>,
312 /// Explicit USD proceeds for the hypothetical sale. Required when `--at` is a future date
313 /// with no bundled dataset price and `--fmv` is not used. Mutually exclusive with `--fmv`.
314 #[arg(long, conflicts_with = "fmv")]
315 proceeds: Option<String>,
316 /// Use the bundled daily-close FMV for `--at` instead of an explicit proceeds amount.
317 /// A future date with no dataset price will return a ProceedsRequired error. Mutually
318 /// exclusive with `--proceeds`.
319 #[arg(long, conflicts_with = "proceeds")]
320 fmv: bool,
321 },
322}
323
324/// `what-if` subcommand tree (task #43). READ-ONLY hypothetical-transaction tax planning: NOTHING is
325/// filed, appended, or persisted. Mirrors the `optimize consult` shape, plus an ad-hoc `TaxProfile`
326/// (so you can plan without `tax-profile set`).
327#[derive(Subcommand)]
328pub enum WhatIf {
329 /// Posit a hypothetical, NON-persisted SALE and see its MARGINAL federal tax: the lots it would
330 /// consume, the ST/LT split, which §1(h) LTCG bracket (0/15/20) it lands in + room to the next
331 /// breakpoint, the exact marginal tax (with-hypothetical minus baseline — the sale's OWN effect,
332 /// not the whole-year figure), the effective rate, the §1212(b) carryforward carried to next year,
333 /// this year's ordinary offset, and the §1411 NIIT delta. A net loss surfaces the carryforward
334 /// disclosure (its value is NOT this-year tax). Writes NOTHING.
335 Sell {
336 /// Hypothetical sale amount (required). Accepts a satoshi integer OR a BTC decimal, e.g.
337 /// `0.05` or `5000000` (a value with a `.` is BTC; a bare integer is satoshis).
338 #[arg(long)]
339 sell: String,
340 /// Wallet to sell from, e.g. `self:cold` or `exchange:coinbase:default` (required; the
341 /// per-wallet pool is mandatory post-2025).
342 #[arg(long)]
343 wallet: Option<String>,
344 /// Sale date for the what-if (YYYY-MM-DD; defaults to today UTC if omitted).
345 #[arg(long)]
346 at: Option<String>,
347 /// USD price per WHOLE BTC for the hypothetical sale (proceeds = price × sat / 1e8). Omit to
348 /// use the bundled daily-close FMV for `--at`; REQUIRED for a future/off-dataset `--at` with no
349 /// bundled price (else the what-if returns a ProceedsRequired error).
350 #[arg(long)]
351 price: Option<String>,
352 /// Lot-selection method for the hypothetical sale: fifo|lifo|hifo. Omit to consume by the
353 /// STANDING method (the account's in-force election / the default), exactly as a real disposal
354 /// on that date would.
355 #[arg(long, value_enum)]
356 method: Option<MethodLotArg>,
357 /// AD-HOC filing status (single|mfj|mfs|hoh|qss). Supplying this (with `--income`) builds a
358 /// NON-persisted profile for the plan instead of the stored `tax-profile`. Omit ALL ad-hoc
359 /// flags to use the stored profile for the sale year.
360 #[arg(long, value_enum)]
361 filing_status: Option<FilingStatusArg>,
362 /// AD-HOC ordinary taxable income EXCLUDING crypto (the base the crypto stacks on). Required
363 /// when building an ad-hoc profile.
364 #[arg(long)]
365 income: Option<String>,
366 /// AD-HOC modified AGI excluding crypto, for the §1411 NIIT threshold. DEFAULTS TO `--income`
367 /// when omitted (never $0 — a $0 MAGI would silently suppress every NIIT disclosure); a printed
368 /// caveat notes the assumption. Supply the true MAGI (incl. QD + non-crypto cap gains) to avoid
369 /// understating NIIT.
370 #[arg(long)]
371 magi: Option<String>,
372 /// AD-HOC §1212(b) LONG-TERM capital-loss carryforward INTO the sale year (optional; defaults
373 /// to $0). The dominant BTC case; short-term carryforward-in is out of scope for the ad-hoc
374 /// profile (set a stored `tax-profile` for that).
375 #[arg(long)]
376 carryforward_in: Option<String>,
377 },
378 /// Posit a hypothetical, NON-persisted HARVEST and find the MAX BTC to sell such that a target holds
379 /// on the ENTIRE prefix [0, N]: `--target zero-ltcg` (sell all that fits in the §1(h) 0% bracket),
380 /// `fifteen-ltcg` (stay at/under 15%), `gain=$X` (realize at most $X of gain WITH this sale), or
381 /// `tax=$X` (add at most $X of marginal federal tax; `tax=$0` is the flagship "zero-tax harvest").
382 /// Uses the STANDING lot method's consumption order (never re-optimized). Discloses the §1212(b)
383 /// carryforward burn, the §1411 NIIT kink (a 0%/15% answer can still cost +3.8%), and the plateau
384 /// notes. The answer is ALWAYS engine-verified. Writes NOTHING.
385 Harvest {
386 /// The harvest target: `zero-ltcg` | `fifteen-ltcg` | `gain=$X` | `tax=$X` (X >= 0). `$` and
387 /// commas are optional (e.g. `gain=25000`, `tax=$0`, `gain=$1,000`).
388 #[arg(long)]
389 target: String,
390 /// Wallet to harvest from, e.g. `self:cold` or `exchange:coinbase:default` (required; the
391 /// per-wallet pool is mandatory post-2025).
392 #[arg(long)]
393 wallet: Option<String>,
394 /// Harvest date for the what-if (YYYY-MM-DD; defaults to today UTC if omitted).
395 #[arg(long)]
396 at: Option<String>,
397 /// USD price per WHOLE BTC. Omit to use the bundled daily-close FMV for `--at`; REQUIRED for a
398 /// future/off-dataset `--at` with no bundled price.
399 #[arg(long)]
400 price: Option<String>,
401 /// AD-HOC filing status (single|mfj|mfs|hoh|qss). Supplying this (with `--income`) builds a
402 /// NON-persisted profile for the plan instead of the stored `tax-profile`. Omit ALL ad-hoc
403 /// flags to use the stored profile for the harvest year.
404 #[arg(long, value_enum)]
405 filing_status: Option<FilingStatusArg>,
406 /// AD-HOC ordinary taxable income EXCLUDING crypto (the base the crypto stacks on). Required
407 /// when building an ad-hoc profile.
408 #[arg(long)]
409 income: Option<String>,
410 /// AD-HOC modified AGI excluding crypto, for the §1411 NIIT threshold. DEFAULTS TO `--income`
411 /// when omitted (never $0 — a $0 MAGI would silently suppress every NIIT disclosure); a printed
412 /// caveat notes the assumption.
413 #[arg(long)]
414 magi: Option<String>,
415 /// AD-HOC §1212(b) LONG-TERM capital-loss carryforward INTO the harvest year (optional; defaults
416 /// to $0) — expands the harvestable-gain room (gains are absorbed before touching the pref stack).
417 #[arg(long)]
418 carryforward_in: Option<String>,
419 },
420}
421
422#[derive(Subcommand)]
423pub enum Reconcile {
424 /// Confirm a self-transfer (TransferLink).
425 LinkTransfer {
426 out: String,
427 #[arg(long, conflicts_with = "to_wallet")]
428 to_event: Option<String>,
429 #[arg(long)]
430 to_wallet: Option<String>,
431 },
432 /// Classify an inbound TransferIn as income.
433 ClassifyInboundIncome {
434 in_ref: String,
435 #[arg(long)]
436 kind: String,
437 #[arg(long)]
438 fmv: Option<String>,
439 #[arg(long)]
440 business: bool,
441 },
442 /// Classify an inbound TransferIn as a received gift.
443 ClassifyInboundGift {
444 in_ref: String,
445 #[arg(long)]
446 fmv_at_gift: String,
447 #[arg(long)]
448 donor_basis: Option<String>,
449 #[arg(long)]
450 donor_acquired: Option<String>,
451 },
452 /// Classify an inbound TransferIn as an inbound self-transfer ("my own coins" returning) —
453 /// non-taxable, creates a fresh lot. `--basis` defaults to $0 (conservative; fires the honest
454 /// zero-basis advisory when omitted); `--acquired` defaults to 1 year + 1 day before receipt
455 /// (assumed long-term for a cold-storage deposit; discloses an advisory so you can correct it).
456 ClassifyInboundSelfTransfer {
457 in_ref: String,
458 #[arg(long)]
459 basis: Option<String>,
460 #[arg(long)]
461 acquired: Option<String>,
462 },
463 /// Reclassify a pending TransferOut.
464 ReclassifyOutflow {
465 out: String,
466 #[arg(long, value_enum)]
467 as_kind: OutKindArg,
468 #[arg(long)]
469 amount: String,
470 #[arg(long)]
471 fee: Option<String>,
472 #[arg(long)]
473 appraisal: bool,
474 /// Free-form donee identifier (e.g. "Alice", "Charity X"). Carried through to
475 /// removals.csv and Form 8283; does not affect tax math.
476 #[arg(long)]
477 donee: Option<String>,
478 },
479 /// Set a manual FMV on an event.
480 SetFmv {
481 event: String,
482 #[arg(long)]
483 fmv: String,
484 },
485 /// Void a revocable decision.
486 Void { target: String },
487 /// Resolve an Unclassified row from a JSON imported payload.
488 ClassifyRaw {
489 target: String,
490 /// A JSON-encoded imported EventPayload (serde externally-tagged: `{"Variant":{...}}`) to
491 /// resolve the Unclassified target as. Must be an IMPORTED variant — Acquire, Income,
492 /// Dispose, TransferOut, TransferIn, or Unclassified. USD fields (usd_cost, fee_usd, …) are
493 /// decimal STRINGS; `sat` is an integer.
494 ///
495 /// FORMAT (Acquire example):
496 /// {"Acquire":{"sat":2000000,"usd_cost":"1680.00","fee_usd":"5.00","basis_source":"ExchangeProvided"}}
497 #[arg(long, verbatim_doc_comment)]
498 payload_json: String,
499 },
500 /// Accept an import conflict.
501 AcceptConflict { conflict: String },
502 /// Reject an import conflict.
503 RejectConflict { conflict: String },
504 /// Path-B safe-harbor allocate (from the actual pre-2025 position).
505 SafeHarborAllocate {
506 #[arg(long, value_enum, default_value_t = MethodArg::Actual)]
507 method: MethodArg,
508 #[arg(long)]
509 attest: bool,
510 },
511 /// Attest an existing allocation as timely.
512 SafeHarborAttest,
513 /// §A.4 Specific-ID: pick the exact lots a disposal consumes.
514 SelectLots {
515 disposal: String,
516 /// One lot pick per --from flag (repeatable). Each PICK is
517 /// `<origin_event_id>#<split_sequence>:<sat>`. The origin_event_id + split come from the
518 /// `lot` column of disposals.csv or the `origin_event`/`split` columns of lots.csv
519 /// (export-snapshot). The total sat across the picks must equal the disposal's principal
520 /// (validated in the fold).
521 ///
522 /// FORMAT (two picks):
523 /// --from import|coinbase|X#0:25000 --from import|river|Y#1:5000
524 #[arg(long = "from", required = true, verbatim_doc_comment)]
525 from: Vec<String>,
526 },
527 /// §A.4 Batch import LotSelections from a CSV (disposal_ref,origin_event_id,split_sequence,sat).
528 ImportSelections {
529 /// CSV of lot picks imported as LotSelection decisions (§A.4). The header is REQUIRED and
530 /// validated loudly; rows sharing a disposal_ref are grouped into a single decision.
531 /// disposal_ref is the disposal event's ref (disposals.csv `event` column); origin_event_id
532 /// is the lot's origin (lots.csv `origin_event` column).
533 ///
534 /// FORMAT (header + one sample row):
535 /// disposal_ref,origin_event_id,split_sequence,sat
536 /// import|gemini|trade|T-2.O-2,import|coinbase|X,0,1000000
537 #[arg(verbatim_doc_comment)]
538 csv: PathBuf,
539 },
540 /// SE-completion Chunk C: flip `business` (and optionally `kind`) on an already-imported Income event.
541 ///
542 /// Corrects the `business: false` hard-code that River (and other adapters) emit at ingest time,
543 /// enabling SE-tax treatment for professional miners / stakers. The engine validates that the target
544 /// event exists and is an Income event — a missing or non-Income target fires a Hard DecisionConflict
545 /// blocker (decision excluded). For TransferIn rows use `classify-inbound-income` instead.
546 ///
547 /// DecisionConflict is Hard — to re-decide, `void` the prior decision first, then re-issue.
548 ReclassifyIncome {
549 /// The Income event reference (from `report` or `income_recognized.csv` 'event' column).
550 income_event: String,
551 /// Whether this income is from a trade or business (true → SE-tax eligible).
552 /// Must be supplied explicitly: `--business true` or `--business false`.
553 #[arg(long, required = true, action = clap::ArgAction::Set)]
554 business: bool,
555 /// Optional income kind correction: mining|staking|interest|airdrop|reward.
556 /// Omit to keep the original kind (only flip `business`).
557 #[arg(long)]
558 kind: Option<String>,
559 },
560 /// Store Form 8283 Section-B donation + appraiser details for a donation event.
561 /// The event ref is the TransferOut EventId from the removals.csv 'event' column.
562 SetDonationDetails {
563 /// TransferOut event reference for the donation (from removals.csv 'event' column).
564 out_event_ref: String,
565 /// Donee organization name (Part IV; required).
566 #[arg(long, required = true)]
567 donee_name: String,
568 /// Donee mailing address (Part IV; optional).
569 #[arg(long)]
570 donee_address: Option<String>,
571 /// Donee EIN (Part IV; required for Section-B completeness).
572 #[arg(long)]
573 donee_ein: Option<String>,
574 /// Qualified appraiser name (Part III; required).
575 #[arg(long, required = true)]
576 appraiser_name: String,
577 /// Appraiser mailing address (Part III; optional).
578 #[arg(long)]
579 appraiser_address: Option<String>,
580 /// Appraiser TIN/SSN/EIN (Part III §6695A; satisfies the TIN-or-PTIN requirement).
581 #[arg(long)]
582 appraiser_tin: Option<String>,
583 /// Appraiser PTIN (Part III §6695A; satisfies the TIN-or-PTIN requirement).
584 #[arg(long)]
585 appraiser_ptin: Option<String>,
586 /// Appraiser qualifications declaration (§170(f)(11)(E)).
587 #[arg(long)]
588 appraiser_qualifications: Option<String>,
589 /// Date the qualified appraisal was made (YYYY-MM-DD).
590 #[arg(long)]
591 appraisal_date: Option<String>,
592 /// FMV determination method override (overrides the section-derived default on the
593 /// Form 8283 carrier row; resolves the Section-A fmv_method deferral when supplied).
594 #[arg(long)]
595 fmv_method: Option<String>,
596 },
597 /// Show stored Form 8283 donation details for a donation event.
598 ShowDonationDetails {
599 /// TransferOut event reference for the donation (from removals.csv 'event' column).
600 out_event_ref: String,
601 },
602 /// Bulk-confirm self-transfers: link every PENDING outbound transfer in a time frame to one
603 /// destination wallet (non-taxable). Shows a preview + requires --yes (or interactive y/N).
604 BulkLinkTransfer {
605 /// Destination wallet every selected outflow links to.
606 #[arg(long)]
607 to_wallet: String,
608 /// Restrict to a single tax year (mutually exclusive with --from/--to).
609 #[arg(long, conflicts_with_all = ["from", "to"])]
610 year: Option<i32>,
611 /// Range start (YYYY-MM-DD; requires --to).
612 #[arg(long, requires = "to")]
613 from: Option<String>,
614 /// Range end (YYYY-MM-DD, inclusive; requires --from).
615 #[arg(long, requires = "from")]
616 to: Option<String>,
617 /// Only outflows FROM this source wallet.
618 #[arg(long)]
619 from_wallet: Option<String>,
620 /// Print the preview and exit without writing.
621 #[arg(long)]
622 dry_run: bool,
623 /// Skip the interactive confirmation (non-interactive apply).
624 #[arg(long)]
625 yes: bool,
626 },
627 /// Bulk-classify unknown-basis inbound deposits as self-transfer-ins ("my own coins"): apply
628 /// Cycle A's `SelfTransferMine` ($0 conservative basis, non-taxable) to MANY pending inbounds in a
629 /// time frame at once. Shows a preview surfacing the total USD given $0 basis (the over-tax
630 /// exposure) + requires --yes (or interactive y/N). Each is a voidable decision; for a deposit
631 /// whose real cost you can substantiate, classify it single-item with `classify-inbound-self-transfer --basis`.
632 BulkClassifyInboundSelfTransfer {
633 /// Restrict to a single tax year (mutually exclusive with --from/--to).
634 #[arg(long, conflicts_with_all = ["from", "to"])]
635 year: Option<i32>,
636 /// Range start (YYYY-MM-DD; requires --to).
637 #[arg(long, requires = "to")]
638 from: Option<String>,
639 /// Range end (YYYY-MM-DD, inclusive; requires --from).
640 #[arg(long, requires = "from")]
641 to: Option<String>,
642 /// Only inbounds received INTO this wallet.
643 #[arg(long)]
644 wallet: Option<String>,
645 /// Print the preview and exit without writing.
646 #[arg(long)]
647 dry_run: bool,
648 /// Skip the interactive confirmation (non-interactive apply).
649 #[arg(long)]
650 yes: bool,
651 },
652 /// Bulk-classify unknown-basis inbound deposits as INCOME (mining|staking|interest|airdrop|reward):
653 /// recognize MANY pending inbounds as ordinary income at their auto-FMV (the daily-close market
654 /// value at receipt) in one confirmed batch, with a UNIFORM `--kind` + `--business` flag. Shows a
655 /// preview surfacing the total income recognized + the count of inbounds EXCLUDED because no price
656 /// was available for their date (those stay pending — an income row with no FMV would year-gate).
657 /// Each is a voidable decision; for a single deposit use `classify-inbound-income`.
658 BulkClassifyInboundIncome {
659 /// Income kind for the whole batch: mining|staking|interest|airdrop|reward.
660 #[arg(long)]
661 kind: String,
662 /// Whether this income is from a trade or business (true → SE-tax eligible).
663 #[arg(long)]
664 business: bool,
665 /// Restrict to a single tax year (mutually exclusive with --from/--to).
666 #[arg(long, conflicts_with_all = ["from", "to"])]
667 year: Option<i32>,
668 /// Range start (YYYY-MM-DD; requires --to).
669 #[arg(long, requires = "to")]
670 from: Option<String>,
671 /// Range end (YYYY-MM-DD, inclusive; requires --from).
672 #[arg(long, requires = "from")]
673 to: Option<String>,
674 /// Only inbounds received INTO this wallet.
675 #[arg(long)]
676 wallet: Option<String>,
677 /// Print the preview and exit without writing.
678 #[arg(long)]
679 dry_run: bool,
680 /// Skip the interactive confirmation (non-interactive apply).
681 #[arg(long)]
682 yes: bool,
683 },
684 /// Bulk-reclassify unknown pending OUTFLOWS as dispositions (Sell|Spend): reclassify MANY pending
685 /// `TransferOut`s as a `Dispose` in one confirmed batch, with the daily-close market value at the
686 /// outflow date as the ESTIMATED proceeds. Shows a preview surfacing the total ESTIMATED proceeds
687 /// AND the total ESTIMATED gain (sum(fmv) - sum(basis)) + the count of outflows EXCLUDED because no price
688 /// was available for their date (those stay pending — a Sell with fabricated proceeds would be a
689 /// SILENT misreport). `--kind` is UNIFORM and accepts ONLY sell|spend (gift/donate are out of
690 /// scope). Each is a voidable decision; for a single outflow use `reclassify-outflow`.
691 BulkReclassifyOutflow {
692 /// Disposition kind for the whole batch: sell|spend (gift/donate rejected — out of scope).
693 #[arg(long)]
694 kind: String,
695 /// Restrict to a single tax year (mutually exclusive with --from/--to).
696 #[arg(long, conflicts_with_all = ["from", "to"])]
697 year: Option<i32>,
698 /// Range start (YYYY-MM-DD; requires --to).
699 #[arg(long, requires = "to")]
700 from: Option<String>,
701 /// Range end (YYYY-MM-DD, inclusive; requires --from).
702 #[arg(long, requires = "from")]
703 to: Option<String>,
704 /// Only outflows from this SOURCE wallet.
705 #[arg(long)]
706 wallet: Option<String>,
707 /// Print the preview and exit without writing.
708 #[arg(long)]
709 dry_run: bool,
710 /// Skip the interactive confirmation (non-interactive apply).
711 #[arg(long)]
712 yes: bool,
713 },
714 /// Bulk-resolve import conflicts: ACCEPT (adopt each new payload) or REJECT (keep each current
715 /// payload) MANY flagged `ImportConflict`s in one confirmed batch. Shows a `current → new` preview,
716 /// then requires --yes (or interactive y/N). Exactly one of --accept / --reject is required. Each
717 /// resolution is NON-REVOCABLE (`SupersedeImport`/`RejectImport` cannot be voided); to resolve a
718 /// conflict differently, exclude it and use single-item `accept-conflict`/`reject-conflict`.
719 #[command(group(clap::ArgGroup::new("resolve_action").required(true).args(["accept", "reject"])))]
720 BulkResolveConflict {
721 /// Accept every listed conflict (adopt each new payload onto its target).
722 #[arg(long)]
723 accept: bool,
724 /// Reject every listed conflict (keep each target's current payload).
725 #[arg(long)]
726 reject: bool,
727 /// Print the preview and exit without writing.
728 #[arg(long)]
729 dry_run: bool,
730 /// Skip the interactive confirmation (non-interactive apply).
731 #[arg(long)]
732 yes: bool,
733 },
734 /// Bulk-void MANY revocable reconcile decisions in one confirmed batch (bulk-void). Shows a preview
735 /// of every voidable decision (the SHARED `voidable_decisions` predicate — effective safe-harbor
736 /// allocations are OMITTED, #7), then requires --yes (or interactive y/N). Each void is
737 /// NON-REVOCABLE (a `VoidDecisionEvent` cannot itself be voided — re-apply the original decision to
738 /// restore). Voiding a `LotSelection` also re-exposes its disposal to the default method and clears
739 /// its optimizer attestation.
740 BulkVoid {
741 /// Print the preview and exit without writing.
742 #[arg(long)]
743 dry_run: bool,
744 /// Skip the interactive confirmation (non-interactive apply).
745 #[arg(long)]
746 yes: bool,
747 },
748 /// Match unreconciled inbound + outbound legs as self-transfers (self-transfer-passthrough C3).
749 /// With no --in/--out: PREVIEW the proposed pairs (read-only). With --in and --out: confirm ONE
750 /// pair (DROP for a same-wallet passthrough, RELOCATE for a cross-wallet transfer). NEVER automatic.
751 MatchSelfTransfers {
752 /// Confirm this in-leg (TransferIn eventref); requires --out.
753 #[arg(long = "in", requires = "out_ref")]
754 in_ref: Option<String>,
755 /// Confirm this out-leg (TransferOut eventref); requires --in.
756 #[arg(long = "out", requires = "in_ref")]
757 out_ref: Option<String>,
758 /// Override the suggested action (else the proposal's topology-derived action is used).
759 #[arg(long, value_enum)]
760 action: Option<SelfTransferActionArg>,
761 /// Print the preview and exit without writing (conflicts with --in/--out).
762 #[arg(long, conflicts_with_all = ["in_ref", "out_ref"])]
763 dry_run: bool,
764 },
765 /// Pseudo-reconcile MODE (sub-project 2): fill deliberately-fictional default decisions at
766 /// projection time (NEVER persisted) to clear the Hard classification blockers — a loudly-flagged
767 /// `[PSEUDO]` on-screen estimate you correct toward truth. `on`/`off` toggle the mode; `approve`
768 /// promotes chosen defaults to real (attested) decisions.
769 #[command(subcommand)]
770 Pseudo(Pseudo),
771}
772
773/// `reconcile pseudo <action>` — the pseudo-reconcile mode sub-verbs (sub-project 2).
774#[derive(Subcommand)]
775pub enum Pseudo {
776 /// Turn pseudo-reconcile mode ON. Projection now synthesizes non-persisted default decisions for
777 /// unresolved unknown-basis inbounds (self-transfer $0), unclassified rows, and import conflicts
778 /// (accept-first); every synthetic contribution is flagged `[PSEUDO]` on screen and BLOCKS export.
779 On,
780 /// Turn pseudo-reconcile mode OFF. Projection reverts to real-only instantly and totally (no
781 /// fictional events were ever written). Already-approved decisions REMAIN (they are real now).
782 Off,
783 /// Promote pseudo default decisions to REAL (attested) decisions in bulk. Shows a preview + requires
784 /// `--yes` (or `--dry-run` to preview only). Optional filters restrict which defaults are approved.
785 Approve {
786 /// Only approve defaults of this TYPE: `self-transfer` (unknown-basis inbound → $0 self-transfer),
787 /// `raw` (unclassified row placeholder), `conflict` (import conflict accept-first), or `fmv`
788 /// (native income FMV synthesized from the daily close). Omit = all.
789 #[arg(long, value_enum)]
790 kind: Option<PseudoKindArg>,
791 /// Only approve defaults whose target event is in this wallet (e.g. `exchange:coinbase:main`).
792 #[arg(long)]
793 wallet: Option<String>,
794 /// Only approve defaults whose target event falls in this tax year.
795 #[arg(long)]
796 year: Option<i32>,
797 /// Print the preview and exit without writing.
798 #[arg(long)]
799 dry_run: bool,
800 /// Skip the interactive confirmation (non-interactive apply).
801 #[arg(long)]
802 yes: bool,
803 },
804}
805
806/// The pseudo-default TYPE filter for `reconcile pseudo approve --kind`.
807#[derive(Clone, Copy, Debug, PartialEq, Eq, ValueEnum)]
808pub enum PseudoKindArg {
809 /// Unknown-basis inbound defaulted to a $0-basis self-transfer-in.
810 SelfTransfer,
811 /// Unclassified row defaulted to a zero-value placeholder (ClassifyRaw).
812 Raw,
813 /// Import conflict defaulted to accept-first (SupersedeImport).
814 Conflict,
815 /// Native income with a missing FMV defaulted to the daily-close value (ManualFmv).
816 Fmv,
817}
818
819#[derive(Copy, Clone, ValueEnum)]
820pub enum SelfTransferActionArg {
821 /// Same-wallet passthrough → SelfTransferPassthrough (both legs skipped, non-taxable).
822 Drop,
823 /// Cross-wallet transfer → TransferLink (relocate the lots to the destination wallet).
824 Relocate,
825}
826
827/// One official form in the `export-irs-pdf` packet (the `--forms` opt-in filter).
828#[derive(Copy, Clone, Debug, PartialEq, Eq, ValueEnum)]
829pub enum FormArg {
830 /// Form 8949 (per-disposition capital-gains rows).
831 F8949,
832 /// Schedule D (aggregated capital-gains totals).
833 ScheduleD,
834 /// Schedule SE (self-employment tax).
835 ScheduleSe,
836 /// Form 8283 (noncash charitable contributions).
837 Form8283,
838 /// Form 1040 (capital-gains cells + the digital-asset question).
839 Form1040,
840}
841
842#[derive(Copy, Clone, ValueEnum)]
843pub enum FilingStatusArg {
844 Single,
845 Mfj,
846 Mfs,
847 Hoh,
848 Qss,
849}
850
851impl From<FilingStatusArg> for FilingStatus {
852 fn from(a: FilingStatusArg) -> Self {
853 match a {
854 FilingStatusArg::Single => FilingStatus::Single,
855 FilingStatusArg::Mfj => FilingStatus::Mfj,
856 FilingStatusArg::Mfs => FilingStatus::Mfs,
857 FilingStatusArg::Hoh => FilingStatus::HoH,
858 FilingStatusArg::Qss => FilingStatus::Qss,
859 }
860 }
861}
862
863#[derive(Copy, Clone, ValueEnum)]
864pub enum FeeArg {
865 C,
866 B,
867}
868
869#[derive(Copy, Clone, ValueEnum)]
870pub enum MethodLotArg {
871 Fifo,
872 Lifo,
873 Hifo,
874}
875
876#[derive(Copy, Clone, ValueEnum)]
877pub enum OutKindArg {
878 Sell,
879 Spend,
880 Gift,
881 Donate,
882}
883
884impl From<MethodLotArg> for LotMethod {
885 fn from(a: MethodLotArg) -> Self {
886 match a {
887 MethodLotArg::Fifo => LotMethod::Fifo,
888 MethodLotArg::Lifo => LotMethod::Lifo,
889 MethodLotArg::Hifo => LotMethod::Hifo,
890 }
891 }
892}
893
894#[derive(Copy, Clone, ValueEnum)]
895pub enum MethodArg {
896 Actual,
897 ProRata,
898}
899
900#[cfg(test)]
901mod tests {
902 use super::*;
903 use clap::CommandFactory;
904
905 /// Render the LONG help (`--help`) of a subcommand identified by its path, recursing into
906 /// nested subcommands (e.g. `["reconcile", "import-selections"]`). Mirrors what a user sees at
907 /// `btctax <path...> --help`, which includes each argument's verbatim long-help.
908 fn long_help_of(path: &[&str]) -> String {
909 let mut cmd = Cli::command();
910 for name in path {
911 cmd = cmd
912 .find_subcommand(name)
913 .unwrap_or_else(|| panic!("subcommand {name:?} exists"))
914 .clone();
915 }
916 cmd.render_long_help().to_string()
917 }
918
919 // Requirement 3, `--help` half: each file/format-taking arg's long-help carries its FORMAT +
920 // a text EXAMPLE. Tokens are comma/brace-joined (no spaces) so help-wrapping can never break
921 // them (verified against the real binary output). This is the single source of truth that
922 // clap_mangen also renders into the per-subcommand man page (Task 2).
923
924 #[test]
925 fn help_documents_key_backup_format() {
926 let h = long_help_of(&["init"]);
927 assert!(
928 h.contains("-----BEGIN PGP PRIVATE KEY BLOCK-----"),
929 "init --key-backup help must document the ASCII-armored key format:\n{h}"
930 );
931 }
932
933 #[test]
934 fn help_documents_backup_key_format() {
935 let h = long_help_of(&["backup-key"]);
936 assert!(
937 h.contains("-----BEGIN PGP PRIVATE KEY BLOCK-----"),
938 "backup-key --out help must document the ASCII-armored key format:\n{h}"
939 );
940 }
941
942 #[test]
943 fn help_documents_export_snapshot_format() {
944 let h = long_help_of(&["export-snapshot"]);
945 // The exact removals.csv header read from the render.rs writer.
946 assert!(
947 h.contains("event,kind,removed_at,lot,sat,basis,fmv_at_transfer"),
948 "export-snapshot --out help must document the projection CSV headers:\n{h}"
949 );
950 }
951
952 #[test]
953 fn help_documents_import_selections_format() {
954 let h = long_help_of(&["reconcile", "import-selections"]);
955 assert!(
956 h.contains("disposal_ref,origin_event_id,split_sequence,sat"),
957 "import-selections help must document the required CSV header:\n{h}"
958 );
959 }
960
961 #[test]
962 fn help_documents_classify_raw_format() {
963 let h = long_help_of(&["reconcile", "classify-raw"]);
964 // The exact externally-tagged serde shape (Usd = decimal string, sat = integer).
965 assert!(
966 h.contains(r#"{"Acquire":{"sat":2000000,"usd_cost":"1680.00","fee_usd":"5.00","basis_source":"ExchangeProvided"}}"#),
967 "classify-raw --payload-json help must document the JSON payload shape:\n{h}"
968 );
969 }
970
971 #[test]
972 fn help_documents_select_lots_format() {
973 let h = long_help_of(&["reconcile", "select-lots"]);
974 assert!(
975 h.contains("import|coinbase|X#0:25000"),
976 "select-lots --from help must document the <event>#<split>:<sat> pick format:\n{h}"
977 );
978 }
979}