#!python

import bdt2cpp
import argparse
import sys

p = argparse.ArgumentParser()
p.add_argument('--print-tree', action='store_true', help='''print the parsed
               tree''')
p.add_argument('model', type=str, help='''filename of the XGBoost model you
                want to transpile''')
p.add_argument('-o', '--output-directory', type=str, default='build', help='''
               output directory to which the transpiled template will be
               written. The files inside will be overwritten without warning!
               Defaults to `build`.''')
p.add_argument('-m', '--max-trees', type=int, default=None, help='''maximum
               number of trees per file''')

args = p.parse_args()

if args.print_tree:
    print(*bdt2cpp.parse_model(args.model), sep='\n\n')
    sys.exit()

bdt2cpp.main(args.model, output_dir=args.output_directory,
             trees_per_file=args.max_trees)
