Skip to main content

contract_cli/commands/
mod.rs

1use crate::cli::{Cli, Commands, ContractCmd};
2use crate::error::Result;
3use crate::output::Ctx;
4
5pub mod agent_info;
6pub mod clauses;
7pub mod clients;
8pub mod config;
9pub mod contracts;
10pub mod doctor;
11pub mod issuers;
12pub mod pack;
13pub mod skill;
14pub mod template;
15pub mod update;
16
17pub fn dispatch(cli: Cli, ctx: Ctx) -> Result<()> {
18    crate::config::ensure_dirs()?;
19    crate::typst_assets::ensure_extracted()?;
20
21    match cli.command {
22        Commands::Issuer(cmd) => issuers::run(cmd, ctx),
23        Commands::Clients(cmd) => clients::run(cmd, ctx),
24        Commands::Contracts(cmd) => contracts::run(cmd, ctx),
25        // Top-level shortcuts (delegate to the contracts handler)
26        Commands::New(args) => contracts::run(ContractCmd::New(args), ctx),
27        Commands::List(args) => contracts::run(ContractCmd::List(args), ctx),
28        Commands::Show { number } => contracts::run(ContractCmd::Show { number }, ctx),
29        Commands::Render(args) => contracts::run(ContractCmd::Render(args), ctx),
30        Commands::Mark { number, status } => {
31            contracts::run(ContractCmd::Mark { number, status }, ctx)
32        }
33        Commands::Sign(args) => contracts::run(ContractCmd::Sign(args), ctx),
34        Commands::Pack(cmd) => pack::run(cmd, ctx),
35        Commands::Template(cmd) => template::run(cmd, ctx),
36        Commands::Config(cmd) => config::run(cmd, ctx),
37        Commands::AgentInfo => agent_info::run(ctx),
38        Commands::Skill(cmd) => skill::run(cmd, ctx),
39        Commands::Doctor => doctor::run(ctx),
40        Commands::Update { check } => update::run(ctx, check),
41    }
42}
43
44pub(crate) fn split_multiline_arg(value: &str) -> Vec<String> {
45    let normalized = value.replace("\\n", "\n");
46    normalized.split('\n').map(|s| s.to_string()).collect()
47}