rivet/main.py

34 lines
1.3 KiB
Python

import argparse
import os
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__":
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. 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(output)