Something went wrong. Try again.
This is a Secret Santa game CLI tool.
Something went wrong. Try again.
1.3 kB · 52 lines
Python
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253"""Main module."""
import argparseimport sysfrom pathlib import Path
from .draws import Drawfrom .models import Gamefrom .notifications import notify
def app() -> None: """Create main app function, entry point for the CLI, using argparse.""" # loads game config parser = argparse.ArgumentParser(description="Secret Santa CLI tool.") parser.add_argument( "config", type=str, help="Path to .yaml file with the configuration of the Secret Santa game.", ) parser.add_argument( "--dry", action="store_true", help="Simulates the game, and doesn't sends the result.", ) parser.add_argument( "--seed", type=str, help="Explicit the seed for the random choices.", default=None, ) args = parser.parse_args() config_file = Path(args.config) if not config_file.is_file(): print("Game config file not found!") sys.exit(1)
# creates the game game = Game.create(config_file=config_file) # runs the draw draw = Draw( participants=game.participants(), exclusions=game.exclusions, seed=args.seed, ) draw.run() # notify the results notify(game=game, draw=draw, dry=args.dry)
if __name__ == "__main__": app()