12 个不稳定版本 (5 个重大变更)

0.6.0 2024 年 5 月 23 日
0.5.6 2024 年 3 月 13 日
0.5.5 2024 年 1 月 6 日
0.5.0 2023 年 9 月 26 日
0.2.2 2021 年 11 月 19 日

#248压缩

Download history 90/week @ 2024-05-23 1/week @ 2024-06-27 14/week @ 2024-07-04 59/week @ 2024-07-25 4/week @ 2024-08-01

每月 63 次下载

MIT 许可证

130KB
2.5K SLoC

vach-cli

vach-cli 是一个简单的 CLI,用于打包、解包和处理 .vach 文件。

对于 vach20 版本,请使用 此版本的 CLI,此版本的 CLI 仅从 vach30 开始使用。


安装

cargo install vach-cli

使用方法

通常遵循模板

vach [subcommand] -[key] [...values]
# List all entries in the archive "source.vach"
vach list -i source.vach

# Pack the files hello.png, click.wav and dialogue.txt into assets.vach
vach pack -i hello.png click.wav dialogue.tx -o assets.vach

# Pack all the file in the directory textures into textures.vach and apply compression
vach pack -d textures -o textures.vach -c

# This lists out the contents of textures.vach
vach list -i textures.vach
┌───────────────────────────┬───────┬────────────┐
│          id               │ size  │   flags    │
├───────────────────────────┼───────┼────────────┤
│   textures/perlin.png     │ 698 B │ Flags[C--] │
│    textures/dirt.png      │ 391 B │ Flags[C--] │
│   textures/cobble.png     │ 733 B │ Flags[C--] │
│    textures/map.json      │ 311 B │ Flags[C--] │
└───────────────────────────┴───────┴────────────┘

命令

  • 运行 vach help 将列出所有命令。每个命令都有其自己的输入。

  • 还可以查看 spec/main.txt 以获取官方规范。

  • 您还可以运行 vach [command] --help 以查看每个单独命令的帮助信息。

  • 由于 CLI 的工作方式,键的位置不重要,因此

    vach list -.vach -m CMYKVvach list -CMYKV -.vach 是等效的。


1: 打包

pack 用于将文件和目录打包到存档中。它接受输入来自定义存档的包装方式。

# Any pack command must have an output, set using the "-o" or "--output" keys
# This builds an empty archive
vach pack -o hello.vach

# You can add files as inputs using the "-i" or "--input" keys
vach pack -o hello.vach -i hello.txt goodbye.txt

# Or add a directory using "-d" or "--directory"
vach pack -o hello.vach -d ./hello

# Add a directory recursively using "-r" or "--directory-r"
vach pack -o hello.vach -r ./hello

# Inputs can be added in tandem
vach pack -o hello.vach -i hi.txt bye.txt -d greetings PR -r talks

# Exclude a given file from the queue
vach pack -x hello/secret.txt -o hello.vach -d hello

# Provide a keypair or secret key for cryptographic use
vach pack -k keypair.kp -o hello.vach -i hello.txt goodbye.txt
vach pack -s secret_key.sk -o hello.vach -i hello.txt goodbye.txt

### MODIFIERS ####
# Compression: "-c always", "-c never" or "-c detect"
vach pack -c always -o hello.vach -i hello.txt goodbye.txt
vach pack -c never -o hello.vach -i hello.txt goodbye.txt

# CompressionAlgorithm: "-g lz4", "-g snappy" or "-g brotli". Both "-g" and "--compress-algo" keys work
vach pack -g lz4 -c always -o hello.vach -i hello.txt goodbye.txt

# Note compression has been set to never here so setting the compression algorithm to be used has no effect
vach pack -g snappy -c never -o hello.vach -i hello.txt goodbye.txt

# Hash: "-a" or "--hash"
# Whether to include signatures in the archive
# This help to detect if the archive has been tampered with
# But it's very computationally intensive so use them sparingly
vach pack -s -o hello.vach -i hello.txt goodbye.txt

# Encrypt: "-e" or "--encrypt"
# Whether to encrypt your archive
# If no pre-existing keypair|secret_key is provided then a new one is written: `${OUTPUT_ARCHIVE}.kp`
# EG hello.vach -> hello.vach.kp, same applies for "-a"
vach pack -e -o hello.vach -i hello.txt goodbye.txt

# Flags: "-f" or "--flags"
# Flags set into the Archive header
# Here the flags are set to 0b1000_1100_1001_0000
vach pack -f 35984 -o hello.vach -i hello.txt goodbye.txt

# Magic: "-m" or "--magic"
# Make your archive unique by setting a custom MAGIC
vach pack -m CMYKX -o hello.vach -i hello.txt goodbye.txt

# Truncate: "-t" or "--truncate"
# This modifier deletes the original files once they are packaged
# hello.txt & goodbye.txt are now deleted
vach pack -t -o hello.vach -i hello.txt goodbye.txt

2: 解包

unpackpack 类似,但相反

# Provide an input: "-i" or "--input"
vach unpack -i target.vach

# Output directory: "-o" or "--output"
# Specify where to unpack the archive
vach unpack -i source.vach -o ./output/

# Specify what magic your archive uses
# Magic: "-m" or "--magic"
vach unpack -m `CMYKX -i source.vach

# Truncate: "-t" or "--truncate"
# Deletes the original archive after unpacking
vach unpack -t -i source.vach

# If the archive is encrypted then provide a keypair or public key
vach unpack -k keypair.kp -i source.vach
vach unpack -s keypair.sk -i source.vach

3: 管道

pipe: 从 特定 条目读取数据并将其管道传输到 stdout

# Print to stdout
vach pipe -i target.vach -r npc-dialogue.txt

# Pipe directly into a file
vach pipe -i target.vach -r npc-dialogue.txt >> npc-dialogue.txt

# Pipe into another process' stdin
vach pipe -i presets.vach -r low.json | jq '."TextureResolution"'

4: 列表

以表格形式列出存档中的所有条目

# Provide some input: "-i" or "--input"
vach list -i textures.vach

# MAGIC: "-m" or "--magic"
# If the archive uses a custom magic
vach list -i textures.vach -m TXTRS

# SORT: "--sort"
# How to sort the entries inside the table
# Can either be: size-ascending, size-descending, alphabetical, alphabetical-reversed
vach list -i textures.vach -m TXTRS --sort size-descending

5: 验证

验证文件的存档有效性

# Simplest command
vach verify -i textures.vach

# MAGIC: "-m" or "--magic"
vach verify -i textures.vach -m TXTRS

6: 密钥对

密钥对生成命令

vach keypair -o keypair.kp
# -> keypair.kp

# Splits the keypair into it's secret and public components immediately after generation
vach keypair -s -o keypair.kp

# -> keypair.pk
# -> keypair.sk

7: 分割

将现有的密钥对分割为其公钥和私钥组件

vach split -i keypair.kp

# -> keypair.pk
# -> keypair.sk

依赖项

~4-12MB
~130K SLoC