bytebeat_compiler.py: add verbose mode for subst.
This commit is contained in:
parent
2f346e7f5f
commit
bd53ac920f
@ -59,9 +59,15 @@ def read_from_file_or_stdin(path: str) -> str:
|
||||
print("The specified file doesn't exist")
|
||||
raise SystemExit
|
||||
|
||||
def substitute_vars(replacements: dict, text: str) -> str:
|
||||
def substitute_vars(replacements: dict, text: str, verbose: bool) -> str:
|
||||
if verbose:
|
||||
print("Substituting values:")
|
||||
for placeholder, replacement in replacements.items():
|
||||
if verbose and placeholder != "bytebeat_contents":
|
||||
print(placeholder, ": ", replacement, sep="")
|
||||
text = text.replace(f"`{placeholder}`", str(replacement))
|
||||
if verbose:
|
||||
print()
|
||||
return text
|
||||
|
||||
CC = fetch("CC")
|
||||
@ -103,6 +109,8 @@ if __name__ == "__main__":
|
||||
help="do not output anything during generation")
|
||||
parser.add_argument("-v", "--verbose", default=False, action="store_true",
|
||||
help="show progress during generation")
|
||||
parser.add_argument("-E", "--show-substituted-values", default=False,
|
||||
action="store_true", help="show substituted values")
|
||||
args = parser.parse_args()
|
||||
|
||||
bytebeat_contents = read_from_file_or_stdin(args.file).strip()
|
||||
@ -164,7 +172,7 @@ if __name__ == "__main__":
|
||||
"silent_mode": "true" if args.silent else "false",
|
||||
"verbose_mode": "true" if args.verbose and not args.silent else "false",
|
||||
"fwrite_le": "../" + PATHS["fwrite_le_header"]
|
||||
}, read_file(PATHS["template"])))
|
||||
}, read_file(PATHS["template"]), args.show_substituted_values))
|
||||
|
||||
# Compile by invoking the shell script
|
||||
print("Compiling")
|
||||
|
Loading…
Reference in New Issue
Block a user