import sys

from compile import do_compile
from link_and_load import link_and_load
import random
import glob

if __name__ == "__main__":
    if len(sys.argv) < 4:
        sys.stderr.write("Expected different parameters!\n")
        sys.stderr.write("    %s address username [file]*\n")
    else:
        address = sys.argv[1]
        username = sys.argv[2]
        files = [a.replace("\\", "/") for a in sum([glob.glob(f) for f in sys.argv[3:]], [])]

        for f in files:
            do_compile(address, f, str(random.random()), f, "CO")

        link_and_load(address, username, files)
