zipatch-rs 1.6.0

Parser for FFXIV ZiPatch patch files
Documentation
//! Command-line inspector. Gated behind the `cli` cargo feature.
//!
//! The public surface is intentionally narrow: a [`Cli`](crate::cli::Cli) clap struct, a
//! [`Commands`](crate::cli::Commands) subcommand enum, and a [`run`](crate::cli::run) entry point. The `zipatch`
//! binary is a one-liner over these.

use std::path::PathBuf;
use std::process::ExitCode;

use clap::{Parser, Subcommand};

mod dump;

/// Top-level CLI parser for the `zipatch` binary.
#[derive(Parser)]
#[command(name = "zipatch", version, about = "Inspect FFXIV ZiPatch files")]
pub struct Cli {
    /// Selected subcommand.
    #[command(subcommand)]
    pub command: Commands,
}

/// Subcommands exposed by the `zipatch` binary.
#[derive(Subcommand)]
pub enum Commands {
    /// Print every chunk in a `.patch` file: offset, tag, size, and for
    /// `SQPK` chunks the sub-command + target path.
    Dump {
        /// Path to the `.patch` file.
        path: PathBuf,
        /// Filter output to SQPK chunks only.
        #[arg(long)]
        sqpk_only: bool,
    },
}

/// Dispatch the parsed CLI to the matching subcommand implementation.
#[must_use]
pub fn run(cli: Cli) -> ExitCode {
    match cli.command {
        Commands::Dump { path, sqpk_only } => dump::run(&path, sqpk_only),
    }
}