import click
import subprocess


@click.group()
def main():
    pass


@main.command()
@click.argument('platform')
def install_minikube(platform):
    try:
        if platform == 'linux':
            subprocess.run(['curl', '-LO',
                            'https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64'], check=True)
            subprocess.run(['sudo', 'install', 'minikube-linux-amd64',
                            '/usr/local/bin/minikube'], check=True)

        elif platform == 'debian':
            subprocess.run(['curl', '-LO',
                            'https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb'], check=True)
            subprocess.run(['sudo', 'dpkg', '-i',
                            'minikube_latest_amd64.deb'], check=True)

        elif platform == 'windows':
            subprocess.run(['curl', '-Lo', 'minikube-installer.exe',
                            'https://storage.googleapis.com/minikube/releases/latest/minikube-installer.exe'], check=True)
            print('Downloaded the Minikube installer for Windows. Run the .exe file to complete the installation.')

        else:
            print('Unsupported platform. Currently, Linux, Debian, and Windows are supported.')

    except subprocess.CalledProcessError as e:
        print('Error installing Minikube:', str(e))


@main.command()
def start_minikube():
    try:
        subprocess.run(['minikube', 'start'], check=True)
    except subprocess.CalledProcessError as e:
        print('Error starting Minikube:', str(e))


if __name__ == "__main__":
    main()
