diff --git a/dnd_item/__init__.py b/dnd_item/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dnd_item/cli.py b/dnd_item/cli.py new file mode 100644 index 0000000..ffbd9f2 --- /dev/null +++ b/dnd_item/cli.py @@ -0,0 +1,30 @@ +import logging +import os + +import typer + +from rich.logging import RichHandler +from rich.console import Console + +from dnd_item.types import Item + + +app = typer.Typer() + + +@app.callback() +def main(): + debug = os.getenv("FANITEM_DEBUG", None) + logging.basicConfig( + format="%(name)s %(message)s", + level=logging.DEBUG if debug else logging.INFO, + handlers=[RichHandler(rich_tracebacks=True, tracebacks_suppress=[typer])], + ) + logging.getLogger('markdown_it').setLevel(logging.ERROR) + + +@app.command() +def item(count: int = typer.Option(1, help="The number of items to generate.")): + console = Console(width=80) + for _ in range(count): + console.print(Item()) diff --git a/dnd_item/types.py b/dnd_item/types.py new file mode 100644 index 0000000..ba0d977 --- /dev/null +++ b/dnd_item/types.py @@ -0,0 +1,2 @@ +class Item: + pass diff --git a/pyproject.toml b/pyproject.toml index fec9d06..ab94310 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ description = "Random item generator for D&D" authors = ["evilchili "] license = "The Unlicense" packages = [ - { include = 'item' }, + { include = 'dnd_item' }, ] [tool.poetry.dependencies] @@ -43,5 +43,5 @@ remove-duplicate-keys = true # remove all duplicate keys in objects remove-unused-variables = true # remove unused variables [tool.poetry.scripts] -fanlang = "item.cli:app" +fanitem = "dnd_item.cli:app"