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.json

  • File 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 it

  • Files or folders listed in the resources field in metadata

input

-i INPUT, --input INPUT

The 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.txt

Then the workplace/ folder would be the input directory

Default: current directory

output

-o OUTPUT, --output OUTPUT

The output directory to store the generated packed plugin

Default: current directory

name

-n NAME, --name NAME

A 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 plugin

For example, with id=my_plugin and version=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.3

If file extension is included in the name and the file extension is a valid Packed Plugin extension (.mcdr or .pyz), then the included file extension will be used. Otherwise the default .mcdr file 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 list

  • Tailing 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_FILE

The 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 directory

Here’s a table of the eventually behavior for --ignore-patterns and --ignore-file:

--ignore-patterns

--ignore-file

Behavior

Unset

Unset

Read the ignore list from .gitignore

Unset

Set

Read the ignore list from given file

Set

Unset

Use patterns from --ignore-patterns

Set

Set

Use patterns from --ignore-patterns

Added in version v2.8.0.

shebang

--shebang SHEBANG

Add a #!-prefixed shebang line at the beginning of the packed plugin. It will also make the packed plugin executable on POSIX

By 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 environment

Example:

--shebang "/usr/bin/env python3"

Added in version v2.8.0.