zipatch_rs/cli/mod.rs
1//! Command-line inspector. Gated behind the `cli` cargo feature.
2//!
3//! The public surface is intentionally narrow: a [`Cli`](crate::cli::Cli) clap struct, a
4//! [`Commands`](crate::cli::Commands) subcommand enum, and a [`run`](crate::cli::run) entry point. The `zipatch`
5//! binary is a one-liner over these.
6
7use std::path::PathBuf;
8use std::process::ExitCode;
9
10use clap::{Parser, Subcommand};
11
12mod dump;
13
14/// Top-level CLI parser for the `zipatch` binary.
15#[derive(Parser)]
16#[command(name = "zipatch", version, about = "Inspect FFXIV ZiPatch files")]
17pub struct Cli {
18 /// Selected subcommand.
19 #[command(subcommand)]
20 pub command: Commands,
21}
22
23/// Subcommands exposed by the `zipatch` binary.
24#[derive(Subcommand)]
25pub enum Commands {
26 /// Print every chunk in a `.patch` file: offset, tag, size, and for
27 /// `SQPK` chunks the sub-command + target path.
28 Dump {
29 /// Path to the `.patch` file.
30 path: PathBuf,
31 /// Filter output to SQPK chunks only.
32 #[arg(long)]
33 sqpk_only: bool,
34 },
35}
36
37/// Dispatch the parsed CLI to the matching subcommand implementation.
38#[must_use]
39pub fn run(cli: Cli) -> ExitCode {
40 match cli.command {
41 Commands::Dump { path, sqpk_only } => dump::run(&path, sqpk_only),
42 }
43}