mod commands;
mod errors;
mod output;
use clap::{Parser, Subcommand};
use std::process;
use std::sync::LazyLock;
static VERSION: LazyLock<String> = LazyLock::new(|| {
format!(
"{} (Typst {})",
env!("CARGO_PKG_VERSION"),
quillmark::typst_version()
)
});
#[derive(Parser)]
#[command(name = "quillmark")]
#[command(about = "Render and check Quillmark documents; inspect and validate quills", long_about = None)]
#[command(version = VERSION.as_str())]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Render(commands::render::RenderArgs),
Check(commands::check::CheckArgs),
Schema(commands::schema::SchemaArgs),
Blueprint(commands::blueprint::BlueprintArgs),
Validate(commands::validate::ValidateArgs),
Info(commands::info::InfoArgs),
Workspace(commands::workspace::WorkspaceArgs),
}
fn main() {
let cli = Cli::parse();
let result = match cli.command {
Commands::Render(args) => commands::render::execute(args),
Commands::Check(args) => commands::check::execute(args),
Commands::Schema(args) => commands::schema::execute(args),
Commands::Blueprint(args) => commands::blueprint::execute(args),
Commands::Validate(args) => commands::validate::execute(args),
Commands::Info(args) => commands::info::execute(args),
Commands::Workspace(args) => commands::workspace::execute(args),
};
if let Err(e) = result {
errors::print_cli_error(&e);
process::exit(1);
}
}