CLI Subcommand - pack
mcdreforged pack [-h] [-i INPUT] [-o OUTPUT] [-n NAME] [--ignore-patterns IGNORE_PATTERN [IGNORE_PATTERN ...]] [--ignore-file IGNORE_FILE] [--shebang SHEBANG]
Pack up your plugin source codes / resources files, from a batch of files, to a .mcdr packed plugin file
The packing is based on the mcdreforged.plugin.json metadata file in the input directory. It will pack and only pack the following files/folders into the packed plugin:
Folder named by the plugin id
File
mcdreforged.plugin.jsonFile
requirements.txt, if it exists. If your plugin relies on third-party Python packages, it is recommended to create this file and declare these Python packages as dependencies within itFiles or folders listed in the resources field in metadata
input
-i INPUT,--input INPUTThe input directory which the plugin is in
For example, if you have following file structure
workplace/ my_plugin/ __init__.py my_lib.py mcdreforged.plugin.json requirements.txtThen the
workplace/folder would be the input directoryDefault: current directory
output
-o OUTPUT,--output OUTPUTThe output directory to store the generated packed plugin
Default: current directory
name
-n NAME,--name NAMEA specific name for the output packed plugin file
If not given it will use the archive_name field in plugin metadata
If it’s still not specific, A default name format will be used
You can use formatter in your name string. String like
{arg_name}in name will be replaced automatically. Use{{or}}for single{or}
id: The plugin id
version: The version of the pluginFor example, with
id=my_pluginandversion=1.2.3, the following formatting will happen
MyCustomPlugin-release->MyCustomPlugin-release
MyCustomPlugin-v{version}->MyCustomPlugin-v1.2.3
{id}_{version}->my_plugin_1.2.3If file extension is included in the name and the file extension is a valid Packed Plugin extension (
.mcdror.pyz), then the included file extension will be used. Otherwise the default.mcdrfile extension will be appended to the end
ignore patterns
--ignore-patterns IGNORE_PATTERN [IGNORE_PATTERN ...]A list of gitignore-like pattern, indicating a set of files and directories to be excluded during plugin packing
It supports a subset of .gitignore syntax. Here are some differences:
When using normal patterns with patterns, i.e. patterns starts with
!, whether a file is excluded depends on the type of the latest matching pattern in the pattern listTailing space character escaping is not supported
Heading hashtag character escaping is not supported
It overwrites values from --ignore-file. It will filter nothing if the value is empty, or the file doesn’t exist or not readable
Notes: The root directory when calculating related path is the current working directory, not the input directory
Default: empty list
Example:
--ignore-patterns __pycache__ foobar/*.txt **/trash/bin/Added in version v2.8.0.
ignore file
--ignore-file IGNORE_FILEThe path to a utf8-encoded gitignore-like file. It’s content will be used as the --ignore-patterns parameter.
Default:
".gitignore", which means that it will automatically read the .gitignore file in the current working directoryHere’s a table of the eventually behavior for
--ignore-patternsand--ignore-file:
--ignore-patterns
--ignore-fileBehavior
Unset
Unset
Read the ignore list from .gitignore
Unset
Set
Read the ignore list from given file
Set
Unset
Use patterns from
--ignore-patternsSet
Set
Use patterns from
--ignore-patternsAdded in version v2.8.0.
shebang
--shebang SHEBANGAdd a
#!-prefixed shebang line at the beginning of the packed plugin. It will also make the packed plugin executable on POSIXBy default no shebang line will be added, and not make the packed plugin file executable
If your packed plugin is a valid python zip app archive, i,e. it contains a working
__main__.py, you can use this option to make your packed plugin executable in bash environmentExample:
--shebang "/usr/bin/env python3"Added in version v2.8.0.