2024-01-28 12:52:45 +00:00
import argparse
2024-03-23 23:30:00 +00:00
import os
2024-01-28 12:52:45 +00:00
2023-11-24 13:34:44 +00:00
from schema import InstructionSetSchema
2024-01-28 12:52:45 +00:00
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
"""
2023-11-24 13:34:44 +00:00
if __name__ == " __main__ " :
2024-01-28 12:52:45 +00:00
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 " )
2024-03-23 23:30:00 +00:00
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 " )
2024-01-28 12:52:45 +00:00
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 ( )
2024-03-23 23:30:00 +00:00
output = args . output
if output is None :
output = os . path . splitext ( args . schema ) [ 0 ] + " .png "
2024-01-28 12:52:45 +00:00
schema = InstructionSetSchema ( args . schema , args . config , args . display )
2024-03-23 23:30:00 +00:00
schema . save ( output )