1#![doc = include_str!("../README.md")]
2
3use camino::Utf8PathBuf;
4use clap::{Parser, Subcommand};
5use machine_check_common::ExecError;
6use thiserror::Error;
7
8pub mod prepare;
9mod translate;
10pub mod verify;
11
12#[derive(Parser, Clone, Debug)]
13#[command(author, version, about, long_about = None)]
14pub struct Cli {
15 #[arg(global = true, short, long)]
17 pub batch: bool,
18 #[arg(global = true, short, long, action = clap::ArgAction::Count)]
20 pub verbose: u8,
21 #[command(subcommand)]
23 pub command: CliSubcommand,
24}
25
26#[derive(Debug, Clone, Subcommand)]
27pub enum CliSubcommand {
28 Prepare(prepare::Cli),
30 Verify(verify::Cli),
32}
33
34pub fn run(args: Cli) -> Result<(), CheckError> {
35 let command = args.command.clone();
36 match command {
37 CliSubcommand::Prepare(prepare) => prepare::prepare(args, prepare),
38 CliSubcommand::Verify(verify) => verify::run(args, verify),
39 }
40}
41
42#[derive(Debug, Error)]
43pub enum CheckError {
44 #[error("{0}")]
45 Machine(String),
46 #[error("{0}")]
47 Translate(String),
48 #[error(transparent)]
49 Compile(#[from] machine_check_compile::Error),
50 #[error(transparent)]
51 ExecError(#[from] ExecError),
52 #[error("could not open file {0}")]
53 OpenFile(Utf8PathBuf, #[source] std::io::Error),
54 #[error("could not read file {0}")]
55 ReadFile(Utf8PathBuf, #[source] std::io::Error),
56 #[error("unknown system type: {0}")]
57 SystemType(String),
58}