#! /usr/bin/env python3

import json
import sys
import calcdb

# Parse arguments

args = sys.argv[1:]
if args != [] and args != ["--min"]:
    print(f"usage: {sys.argv[0]} [--min]", file=sys.stderr)
    sys.exit(1)

minify = ("--min" in args)

# Run conversion

db = calcdb.CalcDB(".")

dictionary = {
  "calcs": db.calcs,
  "lang": { code: db.lang[code].data for code in db.lang },
  "model": db.model,
}

if minify:
    print(json.dumps(dictionary, ensure_ascii=False, separators=(',', ':')))
else:
    print(json.dumps(dictionary, ensure_ascii=False, indent=2))
