Adding basic CLI
This commit is contained in:
@@ -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())
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
class Item:
|
||||||
|
pass
|
||||||
+2
-2
@@ -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"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user