diff --git a/components/l4d2-host-lib/README.md b/components/l4d2-host-lib/README.md new file mode 100644 index 0000000..ac7f61f --- /dev/null +++ b/components/l4d2-host-lib/README.md @@ -0,0 +1 @@ +# l4d2-host-lib diff --git a/components/l4d2-host-lib/pyproject.toml b/components/l4d2-host-lib/pyproject.toml new file mode 100644 index 0000000..d0ecc61 --- /dev/null +++ b/components/l4d2-host-lib/pyproject.toml @@ -0,0 +1,23 @@ +[build-system] +requires = ["setuptools>=68", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "l4d2host" +version = "0.1.0" +description = "L4D2 host library and CLI" +readme = "README.md" +requires-python = ">=3.12" +dependencies = [ + "typer>=0.12", + "PyYAML>=6.0", +] + +[project.scripts] +l4d2ctl = "l4d2host.cli:app" + +[tool.setuptools] +package-dir = {"" = "src"} + +[tool.setuptools.packages.find] +where = ["src"] diff --git a/components/l4d2-host-lib/src/l4d2host/__init__.py b/components/l4d2-host-lib/src/l4d2host/__init__.py new file mode 100644 index 0000000..a05eb9a --- /dev/null +++ b/components/l4d2-host-lib/src/l4d2host/__init__.py @@ -0,0 +1,3 @@ +__all__ = ["__version__"] + +__version__ = "0.1.0" diff --git a/components/l4d2-host-lib/src/l4d2host/cli.py b/components/l4d2-host-lib/src/l4d2host/cli.py new file mode 100644 index 0000000..dd8dddd --- /dev/null +++ b/components/l4d2-host-lib/src/l4d2host/cli.py @@ -0,0 +1,38 @@ +import typer + + +app = typer.Typer(no_args_is_help=True) + + +def _todo() -> None: + raise typer.Exit(code=1) + + +@app.command() +def install() -> None: + _todo() + + +@app.command() +def initialize(name: str, spec: str = typer.Option(..., "--spec", "-f")) -> None: + del name + del spec + _todo() + + +@app.command() +def start(name: str) -> None: + del name + _todo() + + +@app.command() +def stop(name: str) -> None: + del name + _todo() + + +@app.command() +def delete(name: str) -> None: + del name + _todo() diff --git a/components/l4d2-host-lib/tests/test_cli.py b/components/l4d2-host-lib/tests/test_cli.py new file mode 100644 index 0000000..10fb86d --- /dev/null +++ b/components/l4d2-host-lib/tests/test_cli.py @@ -0,0 +1,10 @@ +from typer.testing import CliRunner + +from l4d2host.cli import app + + +def test_help_lists_v1_commands() -> None: + result = CliRunner().invoke(app, ["--help"]) + assert result.exit_code == 0 + for command in ["install", "initialize", "start", "stop", "delete"]: + assert command in result.output