#!/usr/bin/env python

'''
description:    Configuration part of wrfpy
license:        APACHE 2.0
author:         Ronald van Haren, NLeSC (r.vanharen@esciencecenter.nl)
'''

import os
import argparse
from wrfpy.configuration import configuration


def cli_parser():
    '''
    parse command line arguments
    '''
    parser = argparse.ArgumentParser(
      description='WRFpy',
      formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--init', action='store_true',
                        help='Initialize suite')
    parser.add_argument('--create', action='store_true',
                        help='Create suite config')
    parser.add_argument('--basedir', type=str,
                        default=os.path.join(os.path.expanduser("~"),
                                             'cylc-suites'),
                        help="basedir in which suites are installed")
    parser.add_argument('suitename',
                        type=str, help='name of suite')
    results = vars(parser.parse_args())
    # either initialize or create a suite, not both
    if (results['init'] ^ results['create']):
        configuration(results)
    else:
        # print error message to the user, combiniation of --init and --create
        # is not allowed
        print("Only one of '--init' and '--create' is allowed.")
        exit()


if __name__ == "__main__":
    cli_parser()
