#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from kelpie.arg_parser import KelpieArgumentParser
from kelpie.breeder import KelpieBreeder
from kelpie.grazer import KelpieGrazer


def breed(args):
    breeder = KelpieBreeder(input_structure_file=args.input_structure_file,
                            run_location=args.run_location,
                            host_scheduler_settings=args.host_scheduler_settings,
                            custom_scheduler_settings=args.custom_scheduler_settings,
                            batch_script_template=args.batch_script_template,
                            submit_batch_job=args.submit_batch_job,
                            calculation_workflow=args.calculation_workflow,
                            custom_calculation_settings=args.custom_calculation_settings)
    breeder.breed()


def graze(args):
    grazer = KelpieGrazer(run_location=args.run_location,
                          initial_structure_file=args.input_structure_file,
                          calculation_workflow=args.calculation_workflow,
                          custom_calculation_settings=args.custom_calculation_settings)
    grazer.graze()


def main(sys_args):
    prog = 'kelpie'
    description = """Kelpie command line utility to manage VASP runs."""
    arg_parser = KelpieArgumentParser(prog=prog, description=description)
    args = arg_parser.parse_args(sys_args)

    # breeder
    if args.mode == 'breed':
        breed(args)

    if args.mode == 'graze':
        graze(args)


if __name__ == '__main__':
    main(sys.argv[1:])
