Skip to main content

invoice_cli/commands/
mod.rs

1use crate::cli::{Cli, Commands};
2use crate::error::Result;
3use crate::output::Ctx;
4
5pub mod agent_info;
6pub mod clients;
7pub mod config;
8pub mod doctor;
9pub mod invoices;
10pub mod issuers;
11pub mod products;
12pub mod skill;
13pub mod template;
14pub mod update;
15
16pub(crate) fn split_multiline_arg(value: &str) -> Vec<String> {
17    let normalized = value.replace("\\n", "\n");
18    normalized.split('\n').map(|s| s.to_string()).collect()
19}
20
21pub fn dispatch(cli: Cli, ctx: Ctx) -> Result<()> {
22    crate::config::ensure_dirs()?;
23    crate::typst_assets::ensure_extracted()?;
24
25    match cli.command {
26        Commands::Issuers(cmd) => issuers::run(cmd, ctx),
27        Commands::Clients(cmd) => clients::run(cmd, ctx),
28        Commands::Products(cmd) => products::run(cmd, ctx),
29        Commands::Invoices(cmd) => invoices::run(cmd, ctx),
30        Commands::Template(cmd) => template::run(cmd, ctx),
31        Commands::Config(cmd) => config::run(cmd, ctx),
32        Commands::AgentInfo => agent_info::run(ctx),
33        Commands::Skill(cmd) => skill::run(cmd, ctx),
34        Commands::Doctor => doctor::run(ctx),
35        Commands::Update { check } => update::run(ctx, check),
36    }
37}