#!/usr/bin/env python
import click

from rodent import actions


def echo_title(s, text_color='yellow', separator_color='blue'):
    separator = len(s) * '-'
    click.echo(click.style(separator, fg=separator_color))
    click.echo(click.style(s, fg=text_color))
    click.echo(click.style(separator, fg=separator_color))


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


@click.command()
@click.option('-f', '--file-regex')
def list(file_regex=None):
    echo_title("Listing files in scope")
    actions.list_files(file_regex)


@click.command()
@click.option('-f', '--file-regex')
def apply(file_regex=None):
    echo_title("Applying license to files")
    actions.apply(file_regex)


@click.command()
@click.option('-f', '--file-regex')
def check(file_regex=None):
    echo_title("Checking for missing licenses")
    actions.check(file_regex)


cli.add_command(check)
cli.add_command(list)
cli.add_command(apply)

if __name__ == '__main__':
    cli()
