diff --git a/README.md b/README.md index c46680e..09fe491 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,20 @@ Long form: godotpcktool --pack Thrive.pck --action add --remove-prefix extracted --file extracted ``` +The files are added with the specified paths on the command line, but +with the prefix removed. So for example if there was a file called +`extracted/example.png` and `extracted/subfolder/file.txt` and the +above command was used, those files would get added to the pck as +`res://example.png` and `res://subfolder/file.txt`. + +After adding files it is recommended to use the listing command to +view the resulting data inside the pck to verify the expected actions +happened correctly. When a new file matches exactly the path name +inside the pck, it will replace that file. + +To have more control over the resulting paths inside the pck, see the +section below on the JSON commands. + ### Filters Filters can be used to only act on a subset of files in a pck file, or @@ -87,7 +101,7 @@ NOTE: if you use max size to compliment min size extraction, you should subtract one from the size, otherwise you'll operate on the same files twice. -However if you want to work on exactly some size files you can specify the same size twice: +However, if you want to work on exactly some size files you can specify the same size twice: ```sh godotpcktool --min-size-filter 1 --max-size-filter 1 ``` @@ -138,12 +152,54 @@ godotpcktool -i '\.po' -e 'zh' If you need more complex filtering you can specify regular expressions with `--include-override-filter` which makes any file matching any of those regular expression be included in the operation, even if another filter -would cause the file to be excluded. For example you can use this to set +would cause the file to be excluded. For example, you can use this to set file size limits and then override those for specific type: ```sh godotpcktool --min-size-filter 1000 --include-override-filter '\.txt' ``` +#### JSON bulk operations + +To have more control over the resulting paths inside the pck file, +there is a JSON operation API provided. + +To use it, you first need to create a JSON file (`commands.json` in +the example command but any name can be used) with the following +structure (as many files can be specified as required): +```json +[ + { + "file": "/path/to/file", + "target": "overridden/path/file" + }, + { + "file": "LICENSE", + "target": "example/path/LICENSE" + } +] +``` + +Then run the following command to use it (the JSON command can always +be specified when the add operation is used): +```sh +godotpcktool Thrive.pck -a a --command-file commands.json +``` + +This will read `/path/to/file` which can be an absolute or a relative +path, and save it within the pck as `res://overridden/path/file` and +also the `LICENSE` file as `res://example/path/LICENSE`. This way it +is possible to use absolute paths and specify whatever path the file +should end up as in the pck file for maximum control. + +Note that the full path without the `res://` prefix needs to be in the +JSON `target` property for where the file inside the pck should end up +in; this mode doesn't support specifying just the folder so multiple +files with `target` being `pck/folder` will overwrite each other +rather than being placed inside `pck/folder`. So always specify full +paths like `pck/folder/README.txt` rather than `pck/folder/` when +specifying the JSON commands. + + ### Advanced Options #### Specifying Engine Version @@ -158,6 +214,19 @@ godotpcktool NewPack.pck -a a some_file.txt --set-godot-version 3.5.0 Note that this approach **does not** override the engine version number in existing .pck files. This currently only applies to new .pck files. +#### Scripting + +It is possible to use the JSON bulk API without creating a temporary file. This is done by specifying `-` as the file to add and then writing the JSON to the tool's stdin and then closing it. + +```sh +godotpcktool NewPack.pck -a a - +``` + +When starting the above command, the tool will read all lines from stdin until it is closed. At that point the input JSON is +parsed. As stdin needs to be closed for the tool to continue this is not meant for interactive use, but only for scripting. See the above section about the JSON command files for a version usable on the command line. + +See above for the format of the accepted JSON as it is the same as the JSON command file format. + ### General info In the long form multiple files may be included like this: