Allow different output name for generate_opcodes_file.py

This commit is contained in:
Flawed
2024-07-06 09:50:12 -07:00
parent 3be38b0faa
commit 7a34159bc6
+8 -2
View File
@@ -56,8 +56,11 @@ def replace_line_with_new_opcode(line, diff, ver, old_ver):
@click.option( @click.option(
"--reverse", is_flag=True, help="Applies the diff file in the opposite direction" "--reverse", is_flag=True, help="Applies the diff file in the opposite direction"
) )
@click.option(
"-o", "--output", type=click.Path(exists = False, resolve_path=True), help="Output filename"
)
def generate_opcodes_file( def generate_opcodes_file(
old_version_string, new_version_string, diff_file, opcodes_file, reverse old_version_string, new_version_string, diff_file, opcodes_file, reverse, output
): ):
""" """
Parses an OPCODES_FILE and applies a JSON DIFF_FILE to generate a new one. Parses an OPCODES_FILE and applies a JSON DIFF_FILE to generate a new one.
@@ -81,7 +84,10 @@ def generate_opcodes_file(
) )
) )
new_filename = f"Ipcs.{new_version_string}.h" if output:
new_filename = output
else:
new_filename = f"Ipcs.{new_version_string}.h"
with open(new_filename, "w+") as f: with open(new_filename, "w+") as f:
f.writelines(queued_lines) f.writelines(queued_lines)