#!/usr/bin/env python
"""Command line interface to Verso"""

import logging
import click
from git import Repo
from core.logic import get_current_version, get_next_version

@click.group()
def cli():
    """Verso.

    This application provides functionality for managing versioning.

    """
    logging.basicConfig(level=logging.INFO)

def _get_tags():
    return [str(tag) for tag in Repo(".").tags]

@cli.command("current-version")
def current_version():
    """Identify the current version of the project."""
    print(get_current_version(_get_tags()))

@cli.command("next-version")
def next_version():
    """Identify the next version of the project.

    The next version is rather the next _generated_ version of the
    project. If the current version is say 0.1.2, then the next
    version is 0.1.3.

    """
    print(get_next_version(_get_tags()))

if __name__ == '__main__':
    cli()
