Skip to content

Command Line Interface

ShinyHobo edited this page Apr 5, 2024 · 29 revisions

Overview

The multitool provides a CLI with most of the functionality of the GUI, allowing you to unpack and repack files as well as utilize the index and search functions to dump file lists to a file of your choice. I have provided Powershell and CMD example instructions below.

Simply use the extension you want (.zip or .pak) for the destination file, if packing, and it will take care of the rest.

Usage

The cli currently supports unpacking and repacking files.

Short Full Usage
-s --source Selects the input folder/pak
-d --destination Selects the output folder/pak/zip
-v --version Sets the version in the meta.lsx file when packing
-c --compression Determines the level of compression to use when packing (0-4)
-o --out Writes console output to the given file path instead of the console window
-a --append Appends to the output file rather than overwriting it; does nothing if no output file is provided
--create-index Generates a new index, or updates an old one, if new paks are detected
--delete-index Deletes the index; will ask for confirmation
--delete-index-force Deletes the index without confirmation
--search-index Searches the index for the given string and provides the file list returned; requires --index-results
--search-filter Filters the search results by the extensions provided; requires --search-index
--index-results The file to print the index results to
--fast-search Disables the implicit leading wildcard for searches, drastically speeding them up, but may miss results if used incorrectly. Ensure that your search text would normally be preceded by white space.
--help Displays all available commands

Using a level not on this list will result in no compression being used.

Level Type
0 None
1 LZ4
2 LZ4 HC
3 Zlib Fast
4 Zlib Optimal
5 Zstd Fast
6 Zstd Optimal
7 Zstd Max

Examples with Powershell

Pack workspace as .zip

Start-Process -FilePath "/path/to/bg3-modders-multitool.exe" -ArgumentList '-s "/path/to/workspace" -d "/path/to/save/pak.zip" -c 2' -Wait

Unpack .pak

Start-Process -FilePath "/path/to/bg3-modders-multitool.exe" -ArgumentList '-s "/path/to/source/pak.pak" -d "/path/to/unpack/pak"' -Wait

Search index for all .loca and .png files and write results to results.txt

Start-Process -FilePath "/path/to/bg3-modders-multitool.exe" -ArgumentList '--search-index "" --index-results results.txt --search-filter "loca,png"' -Wait

Search index for all GameObjects quickly and write results to results.txt

Start-Process -FilePath "/path/to/bg3-modders-multitool.exe" -ArgumentList '--search-index "id=\"GameObject" --index-results results.txt --fast-search' -Wait

Examples with CMD

These examples use start /wait to ensure that the output stays in order. Redirecting to file output is not available, currently.

Pack workspace as .zip

start /wait "/path/to/bg3-modders-multitool.exe" -s "/path/to/workspace" -d "/path/to/save/pak.zip" -c 2

Unpack .pak

start /wait "/path/to/bg3-modders-multitool.exe" -s "/path/to/source/pak.pak" -d "/path/to/unpack/pak"

Search index for all .loca and .png files and write results to results.txt

start /wait "/path/to/bg3-modders-multitool.exe" --search-index "" --index-results results.txt --search-filter "loca,png"

Search index for all GameObjects quickly and write results to results.txt

start /wait "/path/to/bg3-modders-multitool.exe" --search-index "id=\"GameObject" --index-results results.txt --fast-search

Console Output

All standard information provided by the GUI console is provided, in addition to some color coded messages to make it more readable when viewed using the CLI.

image

VS Code Integration Example

You can place these files inside the folder .vscode in your workspace root, if you'd like. The multitool should automatically ignore any files within directories that start with a period.

build-pak.ps1

$exe = "\path\to\bg3-modders-multitool.exe"
$source = "\path\to\workspace"
$destination = "\path\to\save\pak.zip"
$compression = 1
$version = 1.2.3.4

Start-Process -FilePath "$exe" -ArgumentList "-s `"$source`" -d `"$destination`" -c $compression" -v $version -Wait

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "PowerShell: Launch Script",
            "type": "PowerShell",
            "request": "launch",
            "script": "\\path\\to\\build-pak.ps1",
        }
    ]
}

image

  翻译: