Skip to main content

Command line utilities for DiamondFire templates

Project description

pyrecli

Command line utilities for DiamondFire templates

Installation

Run the following command in a terminal:

pip install pyrecli

Commands

  • scan: Scan all templates on the plot and dump them to a text file (requires CodeClient)
  • send: Send template items to DiamondFire (requires CodeClient)
  • rename: Rename all occurences of a variable (including text codes)
  • script: Generate python scripts from template data
  • grabinv: Save all templates in your Minecraft inventory to a file (requires CodeClient)
  • docs: Generate markdown documentation from template data
  • slice: Slice a template into multiple smaller templates
  • cctoken: Get a reusable CodeClient authentication token

What is this useful for?

  • Backing up a plot
  • Getting an accurate text representation of DF code
  • Open sourcing
  • Version control
  • Large scale refactoring

Example Command Usages

Scan

[Requires CodeClient]

Grabs all of the templates on your current plot and saves them to a file. You will need to run /auth in-game to authorize this action.

Example:

# Dumps all template data into templates.dfts
pyrecli scan templates.dfts

Send

[Requires CodeClient]

Sends all templates in a file back to your inventory.

Example:

pyrecli send templates.dfts

Rename

Renames all occurences of a variable in a list of templates. You can run this command on a single template, or on an entire plot if a variable is used in many places.

This command still requires thorough testing, so make sure you have a backup of your plot before using this command on a large scale.

Example:

# Changes all variables named `foo` to `bar`.
pyrecli rename templates.dfts foo bar

# You can also target a specific scope.
# This changes all occurences of the game variable `plotData` to `gameData`.
pyrecli rename templates.dfts plotData gameData -s game

By default, this modifies the input file in-place, but you can use the --output_path flag to output the renamed templates to a new file:

pyrecli rename templates.dfts foo bar --output_path renamed_templates.dfts

Script

Generates Python scripts from template data.

Example:

# Convert templates into individual scripts and store them in directory `plot_templates`
pyrecli script templates.dfts plot_templates

# Convert templates into scripts and put them into a single file `plot_templates.py`
pyrecli script templates.dfts plot_templates.py --onefile

Grabinv

[Requires CodeClient]

Scans your inventory for templates and saves them to a file.

Example:

# Save inventory templates to `templates.dfts`
pyrecli grabinv templates.dfts

Docs

Generates a Markdown documentation file for a list of templates.

Example:

# Generate documentation and save it to `plot_docs.md`
pyrecli docs templates.dfts plot_docs.md "My Plot Docs"

Slice

Slices a single template into multiple smaller templates. This is useful for resizing templates to fit on a smaller plot.

If multiple templates are passed, only the first one will be used.

NOTE: This feature is not fully implemented yet. Any templates with Control::Return blocks may not work properly if sliced.

Example:

# Slices the first template in `templates.dfts` with a target length of 50 and stores them in `sliced_templates.dfts`
pyrecli slice templates.dfts sliced_templates.dfts 50

CCToken

Returns a CodeClient authentication token that can be used in commands that require CodeClient authorization. This is useful for reducing the amount of times you need to run /auth.

Example:

# Get a token with the read_plot and inventory scopes
pyrecli cctoken mytoken.txt "read_plot inventory"

Command Chaining

You can combine the pipe operator (|) with hyphen (-) file paths to chain multiple commands together.

Example:

# Scans the plot, renames a variable, then sends renamed templates back to DiamondFire
pyrecli scan - | pyrecli rename - foo bar | pyrecli send -

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrecli-0.3.2.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrecli-0.3.2-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file pyrecli-0.3.2.tar.gz.

File metadata

  • Download URL: pyrecli-0.3.2.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pyrecli-0.3.2.tar.gz
Algorithm Hash digest
SHA256 5dc5bd6d6f9f7a1518bd2ec09b46c8cc0f35e01e76a38e7b9059e256d4cdbfff
MD5 a727b6fd8fea991e2c74da2fa58f028d
BLAKE2b-256 270bd491a10f3bc464fe73e54a2704dac65228c90ccf0cfebfdbeb18821af2b4

See more details on using hashes here.

File details

Details for the file pyrecli-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: pyrecli-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pyrecli-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 78d0120d3664fc53c37c78508a66bf929e98e612a6cf5bbaa272e1a604bf05ac
MD5 62f3956f30fc4da3422563c9a8b584db
BLAKE2b-256 762e44a42cab8d30f9b9ff35fe83e6e0afee5a277c770658a352c5cdfefff1a5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page