예제 #1
0
def main():
    args = parse_arguments()
    template_path = str(parent / 'template')

    kwargs = {}

    if args.get('name'):
        kwargs = {
            'no_input': True,
            'extra_context': {
                'project_name': args.get('name'),
                'use_postgres': 'n' if args.get('without_postgres') else 'y',
                'use_redis': 'y' if args.get('redis') else 'n',
            },
        }

    try:
        result = cookiecutter(template_path, **kwargs)
    except OutputDirExistsException as exc:
        echo(
            click.style(
                '\n\nDirectory with such name already exists!\n',
                fg='red',
            ))
        return

    folder = Path(result).name

    echo(click.style(
        '\n\nSuccessfully generated!\n',
        fg='green',
    ))
    echo('cd ' + click.style(f'{folder}/', fg='blue'))
    echo('make run\n\n')
예제 #2
0
def main():
    args = parse_arguments()
    template_path = str(parent / "template")

    kwargs = {}

    if args.get("name"):
        kwargs = {
            "no_input": True,
            "extra_context": {
                "project_name": args.get("name"),
                "use_postgres": "n" if args.get("without_postgres") else "y",
                "use_redis": "y" if args.get("redis") else "n",
                "use_uvloop": "y" if args.get("uvloop") else "n",
            },
        }

    try:
        result = cookiecutter(template_path, **kwargs)
    except (FailedHookException, OutputDirExistsException) as exc:
        if isinstance(exc, OutputDirExistsException):
            echo(
                click.style("\n\nDirectory with such name already exists!\n",
                            fg="red"))
        return

    folder = Path(result).name

    echo(click.style(
        "\n\nSuccessfully generated!\n",
        fg="bright_green",
    ))
    echo("cd " + click.style(f"{folder}/", fg="bright_blue"))
    show_commands(folder)
예제 #3
0
def main():
    args = parse_arguments()
    template_path = str(parent / 'template')

    if not args.get('name'):
        cookiecutter(template_path)
    else:
        ctx = {
            'project_name': args.get('name'),
            'use_postgres': 'n' if args.get('without_postgres') else 'y',
            'use_redis': 'y' if args.get('without_postgres') else 'n',
        }

        cookiecutter(template_path, no_input=True, extra_context=ctx)

    print('\n\nSuccessfully generated!\n')
    print(f'cd {args["name"] or "app"}/')
    print('make run\n\n')