invoice-cli 0.5.13

Beautiful invoices from the CLI — international, stateful, agent-friendly
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
use clap::{Parser, Subcommand};

#[derive(Parser, Debug)]
#[command(name = "invoice", version, about = "Beautiful invoices from the CLI")]
pub struct Cli {
    /// Emit JSON envelope on stdout (auto-detected when piped)
    #[arg(long, global = true)]
    pub json: bool,
    /// Suppress human output
    #[arg(long, global = true)]
    pub quiet: bool,
    #[command(subcommand)]
    pub command: Commands,
}

#[derive(Subcommand, Debug)]
pub enum Commands {
    /// Manage issuers (the companies you invoice AS — supports multiple)
    #[command(visible_alias = "issuer", subcommand)]
    Issuers(IssuerCmd),

    /// Manage clients (the companies you invoice TO)
    #[command(subcommand)]
    Clients(ClientCmd),

    /// Manage reusable products/line-items
    #[command(subcommand)]
    Products(ProductCmd),

    /// Create, list, show, render, or mark invoices
    #[command(subcommand)]
    Invoices(InvoiceCmd),

    /// Template operations (list, preview, set default)
    #[command(subcommand)]
    Template(TemplateCmd),

    /// Show / edit config
    #[command(subcommand)]
    Config(ConfigCmd),

    /// Self-describing JSON manifest for agents
    #[command(alias = "info")]
    AgentInfo,

    /// Install the embedded skill file to ~/.claude/skills/
    #[command(subcommand)]
    Skill(SkillCmd),

    /// Run dependency & config diagnostics
    Doctor,

    /// Self-update from GitHub Releases
    Update {
        /// Don't install, just report latest version
        #[arg(long)]
        check: bool,
    },
}

#[derive(Subcommand, Debug)]
pub enum IssuerCmd {
    /// Add a new issuer
    #[command(alias = "new")]
    Add {
        slug: String,
        #[arg(long)]
        name: String,
        #[arg(long)]
        legal_name: Option<String>,
        #[arg(long, default_value = "sg")]
        jurisdiction: String,
        #[arg(long)]
        tax_registered: bool,
        #[arg(long)]
        tax_id: Option<String>,
        #[arg(long)]
        company_no: Option<String>,
        #[arg(long)]
        address: String,
        #[arg(long)]
        email: Option<String>,
        #[arg(long)]
        phone: Option<String>,
        /// Bank / payment detail line as "Label: Value". Repeat for each
        /// line. Example:
        ///   --bank-line "Bank: DBS" --bank-line "Account: 1234567890"
        ///   --bank-line "Bank Code: 7171" --bank-line "SWIFT: DBSSSGSG"
        /// Lines render as a two-column list on the invoice PDF.
        #[arg(long = "bank-line")]
        bank_line: Vec<String>,
        #[arg(long, default_value = "vienna")]
        template: String,
        /// Path to a logo image (PNG/SVG/JPG). Rendered in template header.
        #[arg(long)]
        logo: Option<String>,
        /// Default directory for `invoices render` output when --out is
        /// omitted. Leading `~/` is expanded. Example:
        ///   --output-dir "~/Documents/Invoices/Paperfoot"
        #[arg(long)]
        output_dir: Option<String>,
        /// Default notes auto-populated into new invoices (free-form
        /// multi-line). Use for payment terms, reverse-charge disclaimers,
        /// etc.
        #[arg(long)]
        notes: Option<String>,
        /// Invoice number format. Tokens: {issuer}, {year}, {seq}, {seq:04}.
        /// Default includes {issuer} so multiple companies cannot collide.
        #[arg(long)]
        number_format: Option<String>,
    },
    /// Edit an existing issuer — pass only the fields you want to change
    Edit {
        slug: String,
        #[arg(long)]
        name: Option<String>,
        #[arg(long)]
        legal_name: Option<String>,
        #[arg(long)]
        jurisdiction: Option<String>,
        #[arg(long)]
        tax_registered: Option<bool>,
        #[arg(long)]
        tax_id: Option<String>,
        #[arg(long)]
        company_no: Option<String>,
        #[arg(long)]
        tagline: Option<String>,
        #[arg(long)]
        address: Option<String>,
        #[arg(long)]
        email: Option<String>,
        #[arg(long)]
        phone: Option<String>,
        /// Bank / payment detail line as "Label: Value". Repeat for each
        /// line. When any --bank-line is passed, REPLACES all existing
        /// bank details on the issuer.
        #[arg(long = "bank-line")]
        bank_line: Vec<String>,
        /// Remove all bank details from the issuer.
        #[arg(long)]
        bank_clear: bool,
        #[arg(long)]
        template: Option<String>,
        #[arg(long)]
        currency: Option<String>,
        #[arg(long)]
        symbol: Option<String>,
        /// Invoice number format. Tokens: {issuer}, {year}, {seq}, {seq:04}.
        /// Use a unique prefix per issuer for globally addressable invoice ids.
        #[arg(long)]
        number_format: Option<String>,
        #[arg(long)]
        logo: Option<String>,
        /// Remove the logo from the issuer (falls back to the star mark).
        #[arg(long)]
        logo_clear: bool,
        /// Default directory for `invoices render` output when --out is
        /// omitted. Leading `~/` is expanded.
        #[arg(long)]
        output_dir: Option<String>,
        /// Default notes auto-populated into new invoices.
        #[arg(long)]
        notes: Option<String>,
    },
    /// Shorthand: change the issuer's default template
    SetTemplate { slug: String, template: String },
    #[command(alias = "ls")]
    List,
    #[command(alias = "get")]
    Show { slug: String },
    #[command(alias = "rm")]
    Delete { slug: String },
}

#[derive(Subcommand, Debug)]
pub enum ClientCmd {
    #[command(alias = "new")]
    Add {
        slug: String,
        #[arg(long)]
        name: String,
        #[arg(long)]
        attn: Option<String>,
        #[arg(long)]
        country: Option<String>,
        #[arg(long)]
        tax_id: Option<String>,
        #[arg(long)]
        address: String,
        #[arg(long)]
        email: Option<String>,
        #[arg(long)]
        notes: Option<String>,
        /// Default issuer slug — `invoices new` uses this when `--as` omitted
        #[arg(long)]
        default_issuer: Option<String>,
        /// Preferred template for this client's invoices
        #[arg(long)]
        default_template: Option<String>,
    },
    /// Edit an existing client — pass only the fields you want to change
    Edit {
        slug: String,
        #[arg(long)]
        name: Option<String>,
        #[arg(long)]
        attn: Option<String>,
        #[arg(long)]
        country: Option<String>,
        #[arg(long)]
        tax_id: Option<String>,
        #[arg(long)]
        address: Option<String>,
        #[arg(long)]
        email: Option<String>,
        #[arg(long)]
        notes: Option<String>,
        #[arg(long)]
        default_issuer: Option<String>,
        #[arg(long)]
        default_template: Option<String>,
    },
    /// Shorthand: pin a default issuer for this client
    SetIssuer { slug: String, issuer_slug: String },
    /// Shorthand: pin a preferred template for this client
    SetTemplate { slug: String, template: String },
    #[command(alias = "ls")]
    List,
    #[command(alias = "get")]
    Show { slug: String },
    #[command(alias = "rm")]
    Delete { slug: String },
}

#[derive(Subcommand, Debug)]
pub enum ProductCmd {
    #[command(alias = "new")]
    Add {
        slug: String,
        #[arg(long)]
        description: String,
        #[arg(long)]
        subtitle: Option<String>,
        #[arg(long, default_value = "unit")]
        unit: String,
        /// Unit price as a decimal (e.g. 220.00)
        #[arg(long)]
        price: String,
        #[arg(long)]
        currency: String,
        #[arg(long, default_value = "0")]
        tax_rate: String,
    },
    /// Edit an existing product — pass only the fields you want to change
    Edit {
        slug: String,
        #[arg(long)]
        description: Option<String>,
        #[arg(long)]
        subtitle: Option<String>,
        #[arg(long)]
        unit: Option<String>,
        #[arg(long)]
        price: Option<String>,
        #[arg(long)]
        currency: Option<String>,
        #[arg(long)]
        tax_rate: Option<String>,
    },
    #[command(alias = "ls")]
    List,
    #[command(alias = "get")]
    Show { slug: String },
    #[command(alias = "rm")]
    Delete { slug: String },
}

#[derive(Subcommand, Debug)]
pub enum InvoiceCmd {
    /// Create a new invoice
    New {
        /// Issuer slug (the "as" — whose invoice is this?). Optional if the
        /// client has a `default_issuer` pinned.
        #[arg(long)]
        r#as: Option<String>,
        /// Client slug
        #[arg(long)]
        client: String,
        /// Item in the form: "product-slug" OR "Description:qty:price:rate"
        #[arg(long = "item")]
        items: Vec<String>,
        /// Due date (e.g. "2026-05-17" or "7d"). Defaults to one week
        /// after issue.
        #[arg(long, default_value = "7d")]
        due: String,
        /// Terms label (default: "Pay in full")
        #[arg(long, default_value = "Pay in full")]
        terms: String,
        #[arg(long)]
        notes: Option<String>,
        /// Currency override (otherwise uses issuer's default)
        #[arg(long)]
        currency: Option<String>,
        /// Reverse-charge flag (EU B2B cross-border)
        #[arg(long)]
        reverse_charge: bool,
        /// Payment URL (Stripe Payment Link, EPC-QR, any URL) encoded as QR
        #[arg(long)]
        pay_link: Option<String>,
        /// Invoice-level discount rate (percent, e.g. "10" for 10% off subtotal)
        #[arg(long)]
        discount_rate: Option<String>,
        /// Invoice-level fixed discount in major units (e.g. "50.00")
        #[arg(long)]
        discount_fixed: Option<String>,
    },
    /// Edit an existing DRAFT invoice's metadata (issued/paid/void invoices
    /// are immutable — use a credit note instead).
    Edit {
        number: String,
        #[arg(long)]
        client: Option<String>,
        #[arg(long)]
        due: Option<String>,
        #[arg(long)]
        terms: Option<String>,
        #[arg(long)]
        notes: Option<String>,
        #[arg(long)]
        currency: Option<String>,
        #[arg(long)]
        pay_link: Option<String>,
        #[arg(long)]
        reverse_charge: Option<bool>,
        #[arg(long)]
        discount_rate: Option<String>,
        #[arg(long)]
        discount_fixed: Option<String>,
    },
    /// Manage line items on a DRAFT invoice
    #[command(subcommand)]
    Items(InvoiceItemCmd),
    /// Issue a credit note against an existing invoice
    CreditNote {
        /// Source invoice number
        number: String,
        /// Copy ALL line items from source and reverse their quantities.
        /// Mutually exclusive with --item.
        #[arg(long, conflicts_with = "items")]
        full: bool,
        /// Explicit items to include on the credit note (same format as
        /// `invoices new --item`). Positive refund amounts are stored as
        /// credits automatically.
        #[arg(long = "item")]
        items: Vec<String>,
        #[arg(long)]
        notes: Option<String>,
        #[arg(long)]
        pay_link: Option<String>,
    },
    /// Ageing report for unpaid invoices, bucketed 0-30 / 31-60 / 61-90 / 90+
    Aging {
        #[arg(long = "as")]
        issuer: Option<String>,
    },
    /// Export invoices as CSV / JSON — month-end accountant handoff
    Export {
        /// YYYY-MM-DD inclusive lower bound on issue_date
        #[arg(long)]
        from: Option<String>,
        /// YYYY-MM-DD inclusive upper bound on issue_date
        #[arg(long)]
        to: Option<String>,
        /// csv | json (default csv)
        #[arg(long, default_value = "csv")]
        format: String,
        /// Output path. Defaults to stdout.
        #[arg(long, short)]
        out: Option<String>,
        #[arg(long = "as")]
        issuer: Option<String>,
    },
    /// Clone an existing invoice's line items into a new draft — same client,
    /// new number + dates. Handy for recurring billing.
    Duplicate {
        number: String,
        /// Override the client (defaults to the source invoice's client)
        #[arg(long)]
        client: Option<String>,
        /// Override the issuer (defaults to the source invoice's issuer)
        #[arg(long = "as")]
        r#as: Option<String>,
        /// New due date (e.g. "2026-05-17" or "7d"). Defaults to "7d".
        #[arg(long, default_value = "7d")]
        due: String,
    },
    #[command(alias = "ls")]
    List {
        #[arg(long)]
        status: Option<String>,
        #[arg(long = "as")]
        issuer: Option<String>,
        /// Only show invoices past due date and not paid/void
        #[arg(long)]
        overdue: bool,
    },
    #[command(alias = "get")]
    Show { number: String },
    /// Render invoice to PDF
    Render {
        number: String,
        /// Template to use (overrides issuer default)
        #[arg(long)]
        template: Option<String>,
        /// Output path (defaults to ./invoice-<number>.pdf)
        #[arg(long, short)]
        out: Option<String>,
        /// Open the PDF after rendering (macOS open / linux xdg-open)
        #[arg(long)]
        open: bool,
    },
    /// Mark status (draft/issued/paid/void)
    Mark { number: String, status: String },
    #[command(alias = "rm")]
    Delete {
        number: String,
        /// Allow deleting a non-draft invoice. Breaks number-sequence
        /// integrity — prefer `mark void` or credit note in most cases.
        #[arg(long)]
        force: bool,
    },
}

#[derive(Subcommand, Debug)]
pub enum InvoiceItemCmd {
    /// Add a line item to a draft invoice
    Add {
        number: String,
        /// Item spec: "product-slug[:qty]" OR "Description:qty:price[:rate]"
        spec: String,
        #[arg(long)]
        subtitle: Option<String>,
        #[arg(long)]
        discount_rate: Option<String>,
        #[arg(long)]
        discount_fixed: Option<String>,
    },
    /// Remove the item at `position` (zero-indexed) from a draft invoice
    #[command(alias = "rm")]
    Remove { number: String, position: i64 },
    /// Edit the item at `position` — any subset of fields
    Edit {
        number: String,
        position: i64,
        #[arg(long)]
        description: Option<String>,
        #[arg(long)]
        subtitle: Option<String>,
        #[arg(long)]
        qty: Option<String>,
        #[arg(long)]
        unit: Option<String>,
        #[arg(long)]
        price: Option<String>,
        #[arg(long)]
        tax_rate: Option<String>,
        #[arg(long)]
        discount_rate: Option<String>,
        #[arg(long)]
        discount_fixed: Option<String>,
    },
}

#[derive(Subcommand, Debug)]
pub enum TemplateCmd {
    #[command(alias = "ls")]
    List,
    /// Render a preview with synthetic data
    Preview {
        name: String,
        #[arg(long, short)]
        out: Option<String>,
    },
}

#[derive(Subcommand, Debug)]
pub enum ConfigCmd {
    Show,
    Path,
    Set { key: String, value: String },
}

#[derive(Subcommand, Debug)]
pub enum SkillCmd {
    Install,
}