#!/usr/bin/env python3
import argparse
from installer.registries import (
    TARGET_REGISTRY,
    OPTION_REGISTRY,
    register_targets,
)

# ====
# MAIN
# ====

# register the installation targets on the registry.
register_targets()

# define a command parser
parser = argparse.ArgumentParser('cli for dotfile installation')
parser.add_argument('--no-sudo', action='store_false', dest='sudo')
parser.add_argument('target', choices=[
    t for t in TARGET_REGISTRY.keys() if not t.startswith('_')
])


if __name__ == '__main__':
    args = parser.parse_args()
    OPTION_REGISTRY.update(args.__dict__)
    TARGET_REGISTRY[args.target]()
