Ejemplo n.º 1
0
def main(ctx: click.Context) -> None:
    """
    Helpful CLI to automate the development workflow.

    - Create and manage your local and remote projects

    - Build projects from cookiecutter templates.

    - Easily create/manage virtual environments.

    - Minimal configuration required.
    """
    # Load the config once on launch of the app and pass it down to the child commands
    # through click's context
    try:
        config = Config.load()
    except FileNotFoundError:
        interactive_config()
    else:
        if not config.can_use_api():
            printer.error(
                "You must set your GitHub username and personal access token to use API"
                " features.",
                exits=1,
            )
        # We have a valid config file at the right place so load it into click's
        # context and pass it down to all subcommands
        ctx.obj = config
Ejemplo n.º 2
0
def test_file_write():
    with tempfile.NamedTemporaryFile(
            "w", delete=False if ON_CI and ON_WINDOWS else True) as file:
        # Make a fake config object
        config = Config(
            projects_dir=Path("some/dir"),
            token="sometoken",
            username="******",
            editor="fakeedit",
            common_packages=["black", "mypy", "flake8"],
            git=False,
        )

        # Write the config
        config.write(path=Path(file.name))

        file_config = Config.load(Path(file.name))

        assert file_config == config
Ejemplo n.º 3
0
def test_from_file_raises_on_missing_file():

    with pytest.raises(FileNotFoundError):
        Config.load(path=Path("not/here.toml"))