From dd2ffebca26f17be634a70c1dcbbbbec10a53eb2 Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Sun, 24 Mar 2024 00:30:00 +0100 Subject: [PATCH] made output default to same name as input --- main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 5d562a2..11c0793 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,5 @@ import argparse +import os from schema import InstructionSetSchema @@ -19,11 +20,15 @@ description = """Examples: if __name__ == "__main__": parser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawTextHelpFormatter) parser.add_argument("schema", help="Path to the schema description. Accepted formats are: YAML, JSON and XML") - parser.add_argument("-o", "--output", help="Output path", default="out.jpg") + parser.add_argument("-o", "--output", help="Output path. By default, the output file will have the same name as the schema description with the extension .png") parser.add_argument("-c", "--config", help="Path to the config file", default="config.json") parser.add_argument("-D", "--display", help="Enable pygame display of the result", action="store_true") args = parser.parse_args() + output = args.output + if output is None: + output = os.path.splitext(args.schema)[0] + ".png" + schema = InstructionSetSchema(args.schema, args.config, args.display) - schema.save(args.output) \ No newline at end of file + schema.save(output) \ No newline at end of file