1pub mod add;
2pub mod archive;
3pub mod digest;
4pub mod doctor;
5pub mod dogear;
6pub mod export;
7pub mod list;
8pub mod promote;
9pub mod resolve;
10pub mod retrospect;
11pub mod schema;
12pub mod sweep;
13pub mod triage;
14pub mod verify;
15
16use crate::cli::{Cli, Command, SchemaTarget};
17use crate::error::{AppError, AppResult};
18use crate::output;
19use jiff::Timestamp;
20
21pub fn validate_args(cli: &Cli) -> AppResult<()> {
24 match &cli.command {
25 Command::Export(args) => export::validate(args),
26 _ => Ok(()),
27 }
28}
29
30pub fn run(cli: Cli, now: Timestamp) -> AppResult<i32> {
31 match cli.command {
32 Command::Add(args) => add::run(args, cli.file, cli.pretty, now),
33 Command::Dogear(args) => dogear::run(args, cli.file, cli.pretty, now),
34 Command::Promote(args) => promote::run(args, cli.file, cli.pretty, now),
35 Command::List(args) => list::run(args, cli.file, cli.pretty, now),
36 Command::Export(args) => export::run(args, cli.file, cli.pretty, now),
37 Command::Triage(args) => triage::run(args, cli.file, cli.pretty),
38 Command::Verify(args) => verify::run(args, cli.file, cli.pretty),
39 Command::Retrospect(args) => retrospect::run(args, cli.file, cli.pretty),
40 Command::Digest(args) => digest::run(args, cli.file, cli.pretty, now),
41 Command::Sweep(args) => sweep::run(args, cli.file, cli.pretty, now),
42 Command::Resolve(args) => resolve::run(args, cli.file, cli.pretty, now),
43 Command::Archive(args) => archive::run(args, cli.file, cli.pretty, now),
44 Command::Schema { target } => run_schema(target, cli.pretty),
45 Command::Doctor(args) => doctor::run(args, cli.file, cli.pretty, now),
46 }
47}
48
49pub fn run_schema(target: SchemaTarget, pretty: bool) -> AppResult<i32> {
50 output::write_success(schema::contract(target), pretty, output::Meta::new())
51 .map_err(|error| AppError::from_io(error, std::path::Path::new("stdout")))?;
52 Ok(0)
53}