import argparse

from dev_tools.build.freeze.build import freeze_build_app
from dev_tools.build.package.build import package_build
from dev_tools.build.source.archive import package_source_archive


def main():
    parser = argparse.ArgumentParser("Clarabot Nano - app builder utility")
    parser.add_argument("--development", action="store_true", default=False)
    parser.add_argument("--skip_package", action="store_true", default=False)
    parser.add_argument("--prefer_archive_package", action="store_true", default=False)
    parser.add_argument("--skip_signing", action="store_true", default=False)
    parser.add_argument("--skip_src_archive", action="store_true", default=False)
    args = parser.parse_args()

    print("Freeze step...")
    frozen_dir, frozen_version = freeze_build_app(args.development, args.skip_signing)

    if args.skip_package:
        print("WARNING: skipping package step!")
    else:
        print("Package step...")
        package_build(args.development, frozen_dir, frozen_version, args.prefer_archive_package, args.skip_signing)

    if args.development or args.skip_src_archive:
        print("WARNING: skipping source archive creation!")
    else:
        package_source_archive(frozen_version)


if __name__ == "__main__":
    main()
