2023-12-04 22:28:03 -08:00
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
2023-12-19 23:52:09 -08:00
|
|
|
from pathlib import Path
|
|
|
|
|
2023-12-04 22:28:03 -08:00
|
|
|
import typer
|
|
|
|
|
|
|
|
from rich.logging import RichHandler
|
|
|
|
from rich.console import Console
|
|
|
|
|
2023-12-23 16:41:21 -08:00
|
|
|
from dnd_item.types import WeaponGenerator, MagicWeaponGenerator
|
2023-12-19 23:52:09 -08:00
|
|
|
from dnd_item import five_e
|
2023-12-04 22:28:03 -08:00
|
|
|
|
|
|
|
app = typer.Typer()
|
2023-12-19 23:52:09 -08:00
|
|
|
app_state = {}
|
2023-12-04 22:28:03 -08:00
|
|
|
|
|
|
|
|
|
|
|
@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)
|
|
|
|
|
2023-12-19 23:52:09 -08:00
|
|
|
app_state['data'] = Path(__file__).parent / Path("sources")
|
|
|
|
|
2023-12-04 22:28:03 -08:00
|
|
|
|
|
|
|
@app.command()
|
2023-12-23 16:41:21 -08:00
|
|
|
def weapon(count: int = typer.Option(1, help="The number of weapons to generate.")):
|
2023-12-19 23:52:09 -08:00
|
|
|
console = Console()
|
2023-12-23 16:41:21 -08:00
|
|
|
for weapon in WeaponGenerator().random(count):
|
|
|
|
console.print(weapon.details)
|
|
|
|
|
|
|
|
|
|
|
|
@app.command()
|
|
|
|
def magic_weapon(count: int = typer.Option(1, help="The number of weapons to generate.")):
|
|
|
|
console = Console()
|
|
|
|
for weapon in MagicWeaponGenerator().random(count):
|
|
|
|
console.print(weapon.details)
|
2023-12-19 23:52:09 -08:00
|
|
|
|
|
|
|
|
|
|
|
@app.command()
|
|
|
|
def convert():
|
|
|
|
src = five_e.weapons()
|
|
|
|
print(src.as_yaml)
|