1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
use clap::Parser;
use std::io;
use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about=None)]
/// This program trains a dictionary from one or more files,
/// to make future compression of similar small files more efficient.
///
/// The dictionary will need to be present during decompression,
/// but if you need to compress many small files individually,
/// it may be worth the trouble.
struct Args {
/// Maximum dictionary size in bytes.
#[arg(short, long)]
max_size: usize,
/// Files to use as input.
files: Vec<PathBuf>,
}
fn main() {
let args = Args::parse();
let dict = zstd::dict::from_files(&args.files, args.max_size).unwrap();
let mut dict_reader: &[u8] = &dict;
io::copy(&mut dict_reader, &mut io::stdout()).unwrap();
}
|