#!/usr/bin/env python3

import argparse
import os

# Parse args
def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument('-p', '--path', type=str)
    parser.add_argument('-d', '--depth', type=str, default=1)
    parser.add_argument('-t', '--type', type=str, choices=["string", "matrix"])
    parser.add_argument('-o', '--output', type=str)
    return parser.parse_args()

if __name__ == "__main__":
    if not os.path.exists(".maxflash_train"):
        os.system("mkdir .maxflash_train")
    args = parse_args()
    path = args.path
    depth = args.depth
    domain = args.type
    oup = args.output
    if oup is None: oup = "model_" + domain + ".json"

    command = "python3 ../src/train/python/main.py " + path + " " + str(depth) + " .maxflash_train C " + domain
    os.system(command)
    model_file = ".maxflash_train/model@depth" + str(depth) + ".json"
    os.system("mv " + model_file + " " + oup)
    os.system("rm -rf .maxflash_train")