Add verbose flag to pack/unpack

This commit is contained in:
Truman Kilen 2023-01-31 22:55:37 -06:00
parent 1d5a2410e8
commit 898be58855

View file

@ -44,6 +44,10 @@ struct ActionUnpack {
/// Base64 encoded AES encryption key if the pak is encrypted /// Base64 encoded AES encryption key if the pak is encrypted
#[arg(short, long)] #[arg(short, long)]
aes_key: Option<String>, aes_key: Option<String>,
/// Verbose
#[arg(short, long, default_value = "false")]
verbose: bool,
} }
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
@ -59,6 +63,10 @@ struct ActionPack {
/// Mount point /// Mount point
#[arg(short, long, default_value = "../../../")] #[arg(short, long, default_value = "../../../")]
mount_point: String, mount_point: String,
/// Verbose
#[arg(short, long, default_value = "false")]
verbose: bool,
} }
#[derive(Subcommand, Debug)] #[derive(Subcommand, Debug)]
@ -148,6 +156,9 @@ fn unpack(args: ActionUnpack) -> Result<(), unpak::Error> {
let mount_point = PathBuf::from(pak.mount_point()); let mount_point = PathBuf::from(pak.mount_point());
let prefix = Path::new(&args.strip_prefix); let prefix = Path::new(&args.strip_prefix);
for file in pak.files() { for file in pak.files() {
if args.verbose {
println!("extracting {}", &file);
}
let file_path = output.join( let file_path = output.join(
mount_point mount_point
.join(&file) .join(&file)
@ -198,12 +209,14 @@ fn pack(args: ActionPack) -> Result<(), unpak::Error> {
); );
for p in paths { for p in paths {
pak.write_file( let rel = &p
&p.strip_prefix(input_path) .strip_prefix(input_path)
.expect("file not in input directory") .expect("file not in input directory")
.to_string_lossy(), .to_string_lossy();
&mut BufReader::new(File::open(&p)?), if args.verbose {
)?; println!("packing {}", &rel);
}
pak.write_file(&rel, &mut BufReader::new(File::open(&p)?))?;
} }
pak.write_index()?; pak.write_index()?;