added command line arguments support

This commit is contained in:
2024-01-28 13:52:45 +01:00
parent 946f4a3b5c
commit 9a032b1ebd
3 changed files with 44 additions and 12 deletions

29
main.py
View File

@@ -1,6 +1,29 @@
import argparse
from schema import InstructionSetSchema
description = """Examples:
- Default theme (black on white):
python main.py schema.xml -o out.jpg
- Dark theme (white on black):
python main.py schema.xml -o out.jpg -c dark.json
- Blueprint theme (white on blue):
python main.py schema.xml -o out.jpg -c blueprint.json
- Transparent background:
python main.py schema.xml -o out.png -c transparent.json
"""
if __name__ == "__main__":
schema = InstructionSetSchema("example1.yaml")
schema.save("example1_v2.jpg")
input()
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("-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()
schema = InstructionSetSchema(args.schema, args.config, args.display)
schema.save(args.output)