#!/usr/bin/env python3

"""run_gen wraps butler_gen with default values."""

import cmd


def gen(web, recipes, directory, debug):
    """
    gen with web files in web and recipes in recipes.

    Generate to directory.

    Will not generate with optimization if debug is True.
    """
    tmpl = 'butler_gen --recipes {} --web {} --directory {} --debug={}'
    if debug:
        debug = 'true'
    else:
        debug = 'false'
    for line in cmd.run(tmpl.format(recipes, web, directory, debug)):
        print(line)


if  __name__ == '__main__':
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('--web', help='directory with web files', default='web')
    parser.add_argument('--recipes', help='directory with recipes',
                        default='book')
    parser.add_argument('--directory', help='directory to generate to',
                        default='build')
    parser.add_argument('--debug', help='generate without optimization',
                        action='store_true')
    args = parser.parse_args()
    gen(args.web, args.recipes, args.directory, args.debug)
