Skip to content

Instantly share code, notes, and snippets.

@adetaylor
Created November 22, 2022 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adetaylor/61f04ec040cd1d5af2e8ba760ffd5fbf to your computer and use it in GitHub Desktop.
Save adetaylor/61f04ec040cd1d5af2e8ba760ffd5fbf to your computer and use it in GitHub Desktop.
use anyhow::Result;
use clap::Parser;
use std::fs::File;
/// Unzip all files within a zip file as quickly as possible.
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
/// Zip file to unzip
#[arg(value_name = "FILE")]
zipfile: PathBuf,
}
fn main() -> Result<()> {
let args = Args::parse();
let zipfile = File::open(args.zipfile)?;
let zip = zip::ZipArchive::new(zipfile)?;
let file_count = zip.len();
println!("Zip has {} files", file_count);
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment