Adding basic CLI

This commit is contained in:
evilchili 2023-12-04 22:28:03 -08:00
parent 466b08d946
commit bc9052242a
4 changed files with 34 additions and 2 deletions

0
dnd_item/__init__.py Normal file
View File

30
dnd_item/cli.py Normal file
View File

@ -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())

2
dnd_item/types.py Normal file
View File

@ -0,0 +1,2 @@
class Item:
pass

View File

@ -5,7 +5,7 @@ description = "Random item generator for D&D"
authors = ["evilchili <evilchili@gmail.com>"] authors = ["evilchili <evilchili@gmail.com>"]
license = "The Unlicense" license = "The Unlicense"
packages = [ packages = [
{ include = 'item' }, { include = 'dnd_item' },
] ]
[tool.poetry.dependencies] [tool.poetry.dependencies]
@ -43,5 +43,5 @@ remove-duplicate-keys = true # remove all duplicate keys in objects
remove-unused-variables = true # remove unused variables remove-unused-variables = true # remove unused variables
[tool.poetry.scripts] [tool.poetry.scripts]
fanlang = "item.cli:app" fanitem = "dnd_item.cli:app"