Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add __main__ file for SDM #59

Merged
merged 2 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ 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. Build Cython code by running `python setup.py`.
Miepee marked this conversation as resolved.
Show resolved Hide resolved
7. 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.
Expand Down
24 changes: 24 additions & 0 deletions src/SuperDuperMetroid/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import json
from SuperDuperMetroid.ROM_Patcher import patch_rom_json
from io import BytesIO
import argparse


def main():
parser = argparse.ArgumentParser()
parser.add_argument("--input-rom-path", type=str, required=True)
Miepee marked this conversation as resolved.
Show resolved Hide resolved
parser.add_argument("--output-rom-path", type=str, required=True)
parser.add_argument("--json-path", type=str, required=True)
args = parser.parse_args()

with open(args.input_rom_path, "rb+") as fh:
Miepee marked this conversation as resolved.
Show resolved Hide resolved
rom_file = BytesIO(fh.read())

with open(args.json_path) as json_contents:
Miepee marked this conversation as resolved.
Show resolved Hide resolved
patch_data = json.load(json_contents)

patch_rom_json(rom_file, args.output_rom_path, patch_data)


if __name__ == "__main__":
main()
Loading