DecompilerMC icon indicating copy to clipboard operation
DecompilerMC copied to clipboard

Improvements for programmatic usage

Open queengooborg opened this issue 7 months ago • 0 comments

This PR performs a number of changes tailored towards improving the experience when using DecompilerMC as a module, rather than as a script.

User Story

I use DecompilerMC as a dependency in a toolkit that reads the source code for Minecraft and calculates all of its items and their crafting recipes, which is then used to generate a worth.yml file for EssentialsX.

However, I had to make some adjustments to its code to get it to work in the manner I desired it to. The primary issue I ran into was that sys.exit() was used quite often throughout the code when there was an error, which means that any script that imported it as a module would also quit on error.

Solution

To improve the experience for module use, as well as to provide other minor improvements, the following changes were made:

  • Replace most instances of sys.exit() with thrown exceptions
  • Use pathlib.Path for most filepaths, rather than strings
  • Don't delete manifest.json after parsing, only when redownloading
    • This allows for partial offline use of DecompilerMC
  • Improves various messages

queengooborg avatar Jul 13 '24 17:07 queengooborg