From e65bef9c22244fc9bcd22a37d335f5f76ba16ff5 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Thu, 26 Sep 2024 10:02:15 +0200 Subject: Create separate packages for library and CLI --- src/flashcard_cli.py | 58 ---------------------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 src/flashcard_cli.py (limited to 'src/flashcard_cli.py') diff --git a/src/flashcard_cli.py b/src/flashcard_cli.py deleted file mode 100644 index be05be8..0000000 --- a/src/flashcard_cli.py +++ /dev/null @@ -1,58 +0,0 @@ -import click -from random import shuffle - -from scheduler import SCHEDULERS -from session import Session -from card import Card - -@click.group() -def cli(): - pass - -def displayCard(card: Card, index: int, random_flip: bool) -> None: - click.echo(click.style(f"{index + 1} ===========================================================", fg="blue")) - - faces = [card.front, card.back] - - if random_flip: - shuffle(faces) - - click.echo(click.style(faces.pop(0), fg="yellow")) - input() - click.echo(faces.pop(0)) - - -@cli.command() -@click.argument("state_file", nargs=1, type=click.Path()) -@click.argument("card_files", nargs=-1, type=click.Path(exists=True)) -@click.option("--scheduler", "scheduler_name", default="brutal", type=click.Choice(SCHEDULERS, case_sensitive=False), help="Name of desired scheduler") -@click.option("--count", default=20, type=int, help="Number of cards to show during the session") -@click.option("--random_flip", is_flag=True, help="Prompt with card front or back randomly instead of always front") -def practice(state_file, card_files, scheduler_name, count, random_flip): - """ - Run a practice session with the specified scheduler, using the provided state and card files. - """ - session = Session(scheduler_name, card_files, state_file) - - for i, card in enumerate(session.practice(count)): - displayCard(card, i, random_flip) - -@cli.command() -@click.argument("state_file", nargs=1, type=click.Path()) -@click.argument("card_files", nargs=-1, type=click.Path(exists=True)) -@click.option("--scheduler", "scheduler_name", default="brutal", type=click.Choice(SCHEDULERS, case_sensitive=False), help="Name of desired scheduler") -@click.option("--count", default=20, type=int, help="Number of cards to show during the session") -@click.option("--random_flip", is_flag=True, help="Prompt with card front or back randomly instead of always front") -def test(state_file, card_files, scheduler_name, count, random_flip): - """ - Run a test session with the specified scheduler, using the provided state and card files. - """ - session = Session(scheduler_name, card_files, state_file) - - for i, (card, correct) in enumerate(session.test(count)): - displayCard(card, i, random_flip) - correct(click.confirm(click.style("Correct?", bold=True))) - -if __name__ == '__main__': - cli() - -- cgit v1.2.3