diff --git a/npc/cli.py b/npc/cli.py index fd25070..96b1c56 100644 --- a/npc/cli.py +++ b/npc/cli.py @@ -1,18 +1,98 @@ from npc.generator.base import generate_npc, npc_type from npc import languages -from rich import print import random import typer +from enum import Enum + +from rich import print + + +class Ancestry(str, Enum): + dragon = 'dragon' + drow = 'drow' + dwarf = 'dwarf' + elf = 'elf' + halfling = 'halfling' + halforc = 'halforc' + highelf = 'highelf' + highttiefling = 'hightiefling' + human = 'human' + tiefling = 'tiefling' + + +class Language(str, Enum): + abyssal = 'abyssal' + celestial = 'celestial' + common = 'commmon' + draconic = 'draconic' + dwarvish = 'dwarvish' + elven = 'elven' + gnomish = 'gnomish' + halfling = 'halfing' + infernal = 'infernal' + orcish = 'orcish' + undercommon = 'undercommon' app = typer.Typer() @app.command() -def npc(ancestry=None, name=None, pronouns=None, title=None, - nickname=None, whereabouts="Unknown", STR=None, DEX=None, CON=None, - INT=None, WIS=None, CHA=None, randomize=False): +def npc( + ancestry: Ancestry = typer.Option( + None, + help='Derive NPC characteristics from a specific ancestry. Randomized if not specified.', + ), + name: str = typer.Option( + None, + help='Specify the NPC name. Randomized names are derived from ancestry', + ), + pronouns: str = typer.Option( + None, + help='Specify the NPC pronouns.', + ), + title: str = typer.Option( + None, + help='Specify the NPC title.', + ), + nickname: str = typer.Option( + None, + help='Specify the NPC nickname.', + ), + whereabouts: str = typer.Option( + None, + help='Specify the NPC whereabouts.', + ), + STR: str = typer.Option( + None, + help='Specify the NPC strength score.', + ), + DEX: str = typer.Option( + None, + help='Specify the NPC dexterity score.', + ), + CON: str = typer.Option( + None, + help='Specify the NPC constitution score.', + ), + INT: str = typer.Option( + None, + help='Specify the NPC intelligence score.', + ), + WIS: str = typer.Option( + None, + help='Specify the NPC wisdom score.', + ), + CHA: str = typer.Option( + None, + help='Specify the NPC charisma score.', + ), + randomize: bool = typer.Option( + False, + help='If True, randomize default stat scores. If False, all stats are 10.' + ), +) -> None: """ Generate a basic NPC. """ @@ -34,14 +114,30 @@ def npc(ancestry=None, name=None, pronouns=None, title=None, @app.command() -def names(ancestry=None, count=1): +def names(ancestry: Ancestry = typer.Option( + None, + help='Derive NPC characteristics from a specific ancestry. Randomized if not specified.', + ), + count: int = typer.Option( + 1, + help='How many names to generate.' + ), +) -> None: for _ in range(int(count)): print(npc_type(ancestry)().full_name) @app.command() -def text(language='common', words=50): - +def text( + language: Language = typer.Option( + 'common', + help='The language for which to generate text.', + ), + count: int = typer.Argument( + 50, + help='How many words to generate.' + ), +) -> None: mod = getattr(languages, language, None) if not mod: print(f'Unsupported Language: {language}.') @@ -54,7 +150,7 @@ def text(language='common', words=50): phrases = [] phrase = [] - for word in [lang.word() for _ in range(int(words))]: + for word in [lang.word() for _ in range(int(count))]: phrase.append(str(word)) if len(phrase) >= random.randint(1, 12): phrases.append(' '.join(phrase))