#!/usr/bin/env python3

from typing import List
import click
import jinjaroot

@click.group(help="jinjaroot command-line client")
def cli():
    pass

@click.command(help="Generate code recursively starting from the current directory")
@click.option('--dry', is_flag=True, help='Dry run do not actually modify')
def generate(dry):
    jinjaroot.generate(dry=dry)

@click.command(help="Verify that the code is up to date - recursively starting from the current directory")
def verify():
    jinjaroot.verify()

@click.command(help="Check for files that may be out of sync between projects")
@click.argument('projects', nargs=-1, required=True)
@click.option('--ask', is_flag=True)
def synctool(projects: List[str], ask: bool):
    if len(projects) < 2:
        raise Exception('At least two arguments required')
    jinjaroot.synctool(projects, ask=ask)

cli.add_command(generate)
cli.add_command(verify)
cli.add_command(synctool)

if __name__ == '__main__':
    cli()