Skip to content

Commit

Permalink
some of the final preps
Browse files Browse the repository at this point in the history
  • Loading branch information
mindsetpro authored Apr 13, 2024
1 parent 32b4566 commit 4551b43
Showing 1 changed file with 32 additions and 14 deletions.
46 changes: 32 additions & 14 deletions src/dblmapi_cli.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
# dblmapi_cli.py
# Copyright (c) 2023-present mindsetpro

import argparse
from dblmapi import process_file, zenkai_file
from colorama import init, Fore
from dblmapi import process_file, generate_csv_table, invert_bytes

# Initialize colorama for cross-platform terminal color support
init(autoreset=True)

def main():
parser = argparse.ArgumentParser(description="dblmapi - A Python module for modding Dragon Ball Legends")
parser.add_argument("--t", dest="task", choices=["stars", "zenkai"], help="Specify the task (stars or zenkai)", required=True)
parser.add_argument("--f", dest="file_path", help="Specify the file path", required=True)

args = parser.parse_args()
parser = argparse.ArgumentParser(description="CLI for modding DB Legends Game files")
parser.add_argument("--filename", help="Path to the DB Legends file", required=True)
parser.add_argument("--task", choices=["process_file", "invert"], help="Choose the mod to perform", required=True)
parser.add_argument("--gen-csv", action="store_true", help="Generate CSV table of file parts and descriptions")

with open(args.file_path, "rb") as file:
content = file.read()
args = parser.parse_args()

if args.task == "stars":
processed_content = process_file(content)
elif args.task == "zenkai":
processed_content = zenkai_file(content)
if args.gen_csv:
generate_csv_table()
print("CSV table generated successfully.")
return

with open("txt/zpower.txt", "wb") as processed_file:
processed_file.write(processed_content)
try:
with open(args.filename, "rb") as file:
file_content = file.read()
if args.task == "process_file":
processed_content = process_file(file_content)
with open(args.filename, "wb") as processed_file:
processed_file.write(processed_content)
print(f"File '{args.filename}' processed successfully.")
elif args.task == "invert":
inverted_content = invert_bytes(file_content)
with open(args.filename, "wb") as inverted_file:
inverted_file.write(inverted_content)
print(f"File '{args.filename}' inverted successfully.")
except FileNotFoundError:
print(Fore.RED + f"Error: File '{args.filename}' not found.")
except ValueError as e:
print(Fore.RED + f"Error: {e}")

if __name__ == "__main__":
main()

0 comments on commit 4551b43

Please sign in to comment.