Skip to main content

hexz_cli/cmd/data/
extract.rs

1//! Reconstruct a safetensors file from a Hexz archive.
2
3use anyhow::Result;
4use hexz_ops::safetensors::extract_safetensors;
5use std::path::PathBuf;
6
7/// Execute the `hexz extract` command.
8pub fn run(input: PathBuf, output: Option<PathBuf>, tensor: Option<String>) -> Result<()> {
9    let output = match output {
10        Some(p) => p,
11        None => input.with_extension("safetensors"),
12    };
13
14    extract_safetensors(&input, &output, tensor.as_deref())?;
15    println!("Extracted: {:?}", output);
16    Ok(())
17}