#!/usr/bin/python3

import argparse
import os

from keyman_config import add_standard_arguments, initialize_logging, initialize_sentry, verify_dbus_running
from keyman_config.get_kmp import get_kmp, keyman_cache_dir


def main():
    parser = argparse.ArgumentParser(description='Download Keyman keyboard package to ~/.cache/keyman')
    parser.add_argument('id', help='Keyman keyboard id')
    add_standard_arguments(parser)

    args = parser.parse_args()

    initialize_logging(args)
    initialize_sentry()
    verify_dbus_running()

    get_kmp(args.id)
    if os.path.exists(os.path.join(keyman_cache_dir(), 'kmpdirlist')):
        os.remove(os.path.join(keyman_cache_dir(), 'kmpdirlist'))


if __name__ == "__main__":
    main()
