Skip to content
This repository was archived by the owner on Jan 17, 2026. It is now read-only.

Conversation

@queengooborg
Copy link

@queengooborg queengooborg commented Jul 13, 2024

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
  • Re-download version manifest if last downloaded 24 hours ago
  • Improves various messages
  • Check each potential Java path and then stop when the first match is found
  • Replace "manual" mode with "interactive" mode
    • The "interactive" mode provides a command line interface to choose the options that could be specified from command line arguments
    • This way, we can specify all the arguments first, and then run all the steps in one go, which makes programmatic usage much easier
  • Simplify command line arguments
    • Rather than having a bunch of command line arguments for each individual step, arguments are now consolidated into a few simple options (clean, force, quiet and interactive)
    • The average user will likely not be configuring most of the CLI options that were removed, and the user that would is probably going to run specific functions from their own script

mat-1 and others added 30 commits June 24, 2022 21:21
This step only happens if running in manual mode, so I can't imagine it's quite useful.
Manual mode is really only helpful for debugging, but not really, because each step can only run if the previous step had.  Implementing the ability to pick and choose steps just adds additional complexity to the program for very little gain.
"--forceno" is on by default, but the only reason to set it to False is to enable interactivity when it detects the conflict.  This just adds more complexity to the code, and the better option is to simply have the user specify "--clean" or "--force" instead.
hube12 pushed a commit that referenced this pull request Nov 2, 2024
- Add the path used to open the program from to all relative paths, so program doesn't create new folders in a directory outside the one it's located within
- Replace sys.exits with exception raising (see #55)
- Replace assertion (which can be compiled out) with unskippable test + exception
- Tweak url['..._mappings'] code so correct exception is raised (#50)
- Standardize pathlib usage
- Some code restructuring to reduce the amount of indentation
- Add some typing
- Grammar fixes in code outputs/errors
- Add TODOs to mark areas for future improvement
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants