diff --git a/README.md b/README.md index c3ebc73..eb4441f 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,14 @@ Super Duper Metroid is a Super Metroid patcher and interface program, intended f # Building Requires an adequate version of python Steps: -1.) Clone this repository -2.) Open a terminal in the repository's root -3.) Create a virtual environment by running `py -3.9 -m venv venv` -4.) Open virtual environment with `venv\scripts\activate` -5.) Install requirements by running `python -m pip install -r requirements.txt` -6.) Build Cython code by running `python setup.py` -7.) Install as editable by running `py -3.9 -m pip install -e .` +1. Clone this repository +2. Open a terminal in the repository's root +3. Create a virtual environment by running `python -m venv venv` +4. Activate the virtual environment with `call venv/bin/activate` on Windows or `source venv/bin/activate` on Unix-based systems +5. Install requirements by running `python -m pip install -r requirements.txt` +6. Install as editable by running `python -m pip install -e .` -You can now run scripts from the project from terminal, using the virtual environment. +You can now run scripts from the project from terminal, using the virtual environment. Or run `python -m Super-Duper-Metroid` to patch the game via a CLI interface. # Credit Credit goes to Samuel Roy for writing most of this code. diff --git a/src/SuperDuperMetroid/__main__.py b/src/SuperDuperMetroid/__main__.py new file mode 100644 index 0000000..d1c06db --- /dev/null +++ b/src/SuperDuperMetroid/__main__.py @@ -0,0 +1,24 @@ +import json +from SuperDuperMetroid.ROM_Patcher import patch_rom_json +from io import BytesIO +import argparse +from pathlib import Path + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--input-rom-path", type=Path, required=True) + parser.add_argument("--output-rom-path", type=Path, required=True) + parser.add_argument("--json-path", type=Path, required=True) + args = parser.parse_args() + + rom_file = BytesIO(args.input_rom_path.read_bytes()) + + with args.json_path.open() as json_contents: + patch_data = json.load(json_contents) + + patch_rom_json(rom_file, args.output_rom_path, patch_data) + + +if __name__ == "__main__": + main()