37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
import click
|
|
import os
|
|
from custom_bingo.card_generator import generate_bingo_cards
|
|
from custom_bingo.spreadsheet_reader import read_spreadsheet
|
|
from custom_bingo.pdf_generator import export_cards_to_pdf
|
|
|
|
|
|
@click.command()
|
|
@click.option('--input-file', '-i', required=True, type=click.Path(exists=True),
|
|
help='Input spreadsheet file (Excel/CSV) with B, I, N, G, O columns')
|
|
@click.option('--output-file', '-o', required=True, type=click.Path(),
|
|
help='Output PDF file for the BINGO cards')
|
|
@click.option('--number-of-cards', '-n', default=1, type=int,
|
|
help='Number of BINGO cards to generate (default: 1)')
|
|
def main(input_file, output_file, number_of_cards):
|
|
"""Generate custom BINGO cards from a spreadsheet."""
|
|
try:
|
|
# Read the spreadsheet data
|
|
click.echo(f"Reading data from {input_file}...")
|
|
data = read_spreadsheet(input_file)
|
|
|
|
# Generate the bingo cards
|
|
click.echo(f"Generating {number_of_cards} BINGO card(s)...")
|
|
cards = generate_bingo_cards(data, number_of_cards)
|
|
|
|
# Export to PDF
|
|
click.echo(f"Exporting cards to {output_file}...")
|
|
export_cards_to_pdf(cards, output_file)
|
|
|
|
click.echo(f"Successfully generated {number_of_cards} BINGO card(s) in {output_file}")
|
|
except Exception as e:
|
|
click.echo(f"Error: {str(e)}", err=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|