initialization

This commit is contained in:
evilchili 2025-09-21 13:44:59 -07:00
parent c4f5a37234
commit 17d9fea56b
5 changed files with 126 additions and 0 deletions

54
pyproject.toml Normal file
View File

@ -0,0 +1,54 @@
[tool.poetry]
name = "ttfrog"
version = "1.0"
description = "ttfrog: automatically generated by poetry-slam."
authors = ["greg"]
readme = "README.md"
packages = [
{include = "*", from = "src"},
]
[tool.poetry.dependencies]
python = "^3.11"
python-dotenv = "^0.21.0"
rich = "^13.7.0"
typer = "^0.9.0"
[tool.poetry.group.dev.dependencies]
pytest = "^8.4.2"
pytest-cov = "^7.0.0"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.poetry.scripts]
ttfrog = "ttfrog.cli:app"
### SLAM
[tool.black]
line-length = 120
target-version = ['py310']
[tool.isort]
multi_line_output = 3
line_length = 120
include_trailing_comma = true
[tool.autoflake]
check = false # return error code if changes are needed
in-place = true # make changes to files instead of printing diffs
recursive = true # drill down directories recursively
remove-all-unused-imports = true # remove all unused imports (not just those from the standard library)
ignore-init-module-imports = true # exclude __init__.py when removing unused imports
remove-duplicate-keys = true # remove all duplicate keys in objects
remove-unused-variables = true # remove unused variables
[tool.pytest.ini_options]
log_cli_level = "DEBUG"
addopts = "--cov=src --cov-report=term-missing"
### ENDSLAM

0
src/ttfrog/__init__.py Normal file
View File

57
src/ttfrog/cli.py Normal file
View File

@ -0,0 +1,57 @@
import io
import logging
from pathlib import Path
from typing import Optional
import typer
from dotenv import load_dotenv
from rich.logging import RichHandler
CONFIG_DEFAULTS = """
# ttfrog Defaults
LOG_LEVEL=INFO
"""
app = typer.Typer()
app_state = dict(
config_file=Path("~/.config/ttfrog.conf").expanduser(),
)
logger = logging.getLogger("ttfrog.cli")
@app.callback(invoke_without_command=True)
def main(
context: typer.Context,
verbose: bool = typer.Option(False, help="Enable verbose output."),
log_level: str = typer.Option("error", help=" Set the log level."),
config_file: Optional[Path] = typer.Option(
app_state["config_file"],
help="Path to the ttfrog configuration file",
),
):
"""
Configure the execution environment with global parameters.
"""
app_state["config_file"] = config_file
load_dotenv(stream=io.StringIO(CONFIG_DEFAULTS))
load_dotenv(app_state["config_file"])
logging.basicConfig(
format="%(message)s",
level=getattr(logging, log_level.upper()),
handlers=[RichHandler(rich_tracebacks=True, tracebacks_suppress=[typer])],
)
app_state["verbose"] = verbose
if context.invoked_subcommand is None:
logger.debug("No command specified; invoking default handler.")
run(context)
def run(context: typer.Context):
"""
The default CLI entrypoint is ttfrog.cli.run().
"""
raise NotImplementedError("Please define ttfrog.cli.run().")

7
test/test_ttfrog.py Normal file
View File

@ -0,0 +1,7 @@
import pytest
@pytest.mark.xfail
def test_tests_are_implemented():
print("Yyou have not implemented any tests yet.")
assert False

8
test/test_ttfrog_cli.py Normal file
View File

@ -0,0 +1,8 @@
import pytest
from ttfrog import cli
@pytest.mark.xfail
def test_tests_are_implemented():
assert cli.main()