#!/usr/bin/python3
"""

Main script for generating the apps in the home menu.

Copyright (C) 2018, Guillaume Gonnet
License MIT

"""

import os.path as path
import sys
import argparse


# Push 'apps' folder for loading 'genapps'
folder = path.join(path.dirname(__file__), 'apps')
sys.path.append(path.abspath(folder))

from genapps import genapps


def main():
    "Entry point of the application."

    parser = argparse.ArgumentParser(prog="makeapps",
        description="Main script for generating the apps in the home menu.")

    args = parser.add_argument("-asm", default=None, metavar="filename",
        help="Generate only the ASM data in *filename*.")

    args = parser.add_argument("-ld", default=None, metavar="filename",
        help="Generate only the LD script in *filename*.")

    args = parser.parse_args()
    here = path.dirname(__file__)

    appsfolder = path.abspath(path.join(here, "../apps"))
    if args.asm: args.asm = path.abspath(args.asm)
    if args.ld: args.ld = path.abspath(args.ld)

    genapps(appsfolder, args.asm, args.ld)


if __name__ == "__main__":
    main()
