From bd0a10121af582de18b911431d21369a91997abb Mon Sep 17 00:00:00 2001 From: Truman Kilen Date: Fri, 6 Oct 2023 16:14:08 -0500 Subject: [PATCH] Add cmd help to readme + test --- README.md | 19 +++++++++++++++++++ repak_cli/Cargo.toml | 3 +++ repak_cli/tests/docs.rs | 24 ++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 repak_cli/tests/docs.rs diff --git a/README.md b/README.md index a0a16a8..921d4bf 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,25 @@ Library and CLI tool for working with Unreal Engine .pak files. - 2x faster unpacking over `UnrealPak`. As much as 30x faster has been observed (on Linux unpacked to ramdisk) - Unpacking is guarded against malicious pak that attempt to write to parent directories +## cli +``` +Usage: repak [OPTIONS] + +Commands: + info Print .pak info + list List .pak files + hash-list List .pka files and the SHA256 of their contents. Useful for finding differences between paks + unpack Unpack .pak file + pack Pack directory into .pak file + get Reads a single file to stdout + help Print this message or the help of the given subcommand(s) + +Options: + -a, --aes-key 256 bit AES encryption key as base64 or hex string if the pak is encrypted + -h, --help Print help + -V, --version Print version +``` + ## compatibility | UE Version | Version | Version Feature | Read | Write | diff --git a/repak_cli/Cargo.toml b/repak_cli/Cargo.toml index b31338b..5ff6f4f 100644 --- a/repak_cli/Cargo.toml +++ b/repak_cli/Cargo.toml @@ -26,3 +26,6 @@ path-slash = "0.2.1" rayon = "1.6.1" sha2 = "0.10.7" strum = { workspace = true } + +[dev-dependencies] +assert_cmd = "2.0.12" diff --git a/repak_cli/tests/docs.rs b/repak_cli/tests/docs.rs new file mode 100644 index 0000000..9494ff3 --- /dev/null +++ b/repak_cli/tests/docs.rs @@ -0,0 +1,24 @@ +fn workspace_dir() -> std::path::PathBuf { + let output = std::process::Command::new(env!("CARGO")) + .arg("locate-project") + .arg("--workspace") + .arg("--message-format=plain") + .output() + .unwrap() + .stdout; + let cargo_path = std::path::Path::new(std::str::from_utf8(&output).unwrap().trim()); + cargo_path.parent().unwrap().to_path_buf() +} + +#[test] +fn test_readme_help() { + use assert_cmd::prelude::*; + use std::process::Command; + + let err = Command::cargo_bin("repak").unwrap().unwrap_err(); + let help = std::str::from_utf8(&err.as_output().unwrap().stderr).unwrap(); + + let readme = std::fs::read_to_string(workspace_dir().join("README.md")).unwrap(); + + assert!(readme.contains(&format!("```\n{help}```"))); +}