#coding=utf-8

from buildz.tools import *
from buildz import ioc,xf
import sys
from .tools import res, rfp
import os

notices = """
注：程序声音是代码生成的，不是自然音，如果声音播放后感觉不舒服，别用这个程序，有问题可发邮件联系

Notice: sounds in this program is generated by codes, not natural sound, if feel uncomfortable run this program, stop using it, contacting by email if you has questions.
"""
def build(fp_env=None):
    print(notices)
    mg = ioc.build()
    fps = fz.search(os.path.join(res, "ioc"), ".*\.js")
    mg.add_fps(fps)
    if fp_env is not None:
        fp_env = rfp(fp_env)
        envs = xf.loadf(fp_env)
        mg.set_envs(envs)
    print("initializing...")
    return mg

pass
def run():
    fp_env = "default_env.js"
    if len(sys.argv)>1:
        fp_env = sys.argv[1]
    mg = build(fp_env)
    key = mg.get("obj.main")
    mg.get(key)

pass