Add cmd help to readme + test

This commit is contained in:
Truman Kilen 2023-10-06 16:14:08 -05:00
parent 6bd3be3aca
commit bd0a10121a
3 changed files with 46 additions and 0 deletions

View file

@ -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] <COMMAND>
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 <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 |

View file

@ -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"

24
repak_cli/tests/docs.rs Normal file
View file

@ -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}```")));
}