# Path: bottery/cli.py
# @click.group(invoke_without_command=True)
# @click.option('--version', '-v', is_flag=True, default=False)
# @click.pass_context
# def cli(ctx, version):
#     """Bottery"""
# 
#     # If no subcommand was given and the version flag is true, shows
#     # Bottery version
#     if not ctx.invoked_subcommand and version:
#         click.echo(bottery.__version__)
#         ctx.exit()
# 
#     # If no subcommand but neither the version flag, shows help message
#     elif not ctx.invoked_subcommand:
#         click.echo(ctx.get_help())
#         ctx.exit()


import os
import bottery
from click.testing import CliRunner
from bottery.cli import cli




def test_startproject():
    runner = CliRunner()
    with runner.isolated_filesystem():
        project_name = 'librarybot'
        project_files = {
            'handlers.py',
            'settings.py',
            'views.py',
            'wsgi.py'
        }

        result = runner.invoke(cli, ['startproject', project_name])

        assert result.exit_code == 0
        assert os.listdir() == [project_name]
        assert set(os.listdir(project_name)) == project_files


def test_startproject_invalid_project_name():
    runner = CliRunner()
    with runner.isolated_filesystem():
        project_name = 'library-bot'

# Path: bottery/cli.py
# @click.group(invoke_without_command=True)
# @click.option('--version', '-v', is_flag=True, default=False)
# @click.pass_context
# def cli(ctx, version):
#     """Bottery"""
# 
#     # If no subcommand was given and the version flag is true, shows
#     # Bottery version
#     if not ctx.invoked_subcommand and version:
#         click.echo(bottery.__version__)
#         ctx.exit()
# 
#     # If no subcommand but neither the version flag, shows help message
#     elif not ctx.invoked_subcommand:
#         click.echo(ctx.get_help())
#         ctx.exit()


# Path: tests/test_cli.py
import os
import bottery
from click.testing import CliRunner
from bottery.cli import cli





def test_startproject():
    runner = CliRunner()
    with runner.isolated_filesystem():
        project_name = 'librarybot'
        project_files = {
            'handlers.py',
            'settings.py',
            'views.py',
            'wsgi.py'
        }

        result = runner.invoke(cli, ['startproject', project_name])

        assert result.exit_code == 0
        assert os.listdir() == [project_name]
        assert set(os.listdir(project_name)) == project_files


def test_startproject_invalid_project_name():
    runner = CliRunner()
    with runner.isolated_filesystem():
        project_name = 'library-bot'

        result = runner.invoke(cli, ['startproject', project_name])