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