summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/flashcard_cli.py37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/flashcard_cli.py b/src/flashcard_cli.py
index 8017c4d..be05be8 100644
--- a/src/flashcard_cli.py
+++ b/src/flashcard_cli.py
@@ -9,6 +9,19 @@ from card import Card
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))
@@ -22,16 +35,7 @@ def practice(state_file, card_files, scheduler_name, count, random_flip):
session = Session(scheduler_name, card_files, state_file)
for i, card in enumerate(session.practice(count)):
- click.echo(click.style(f"{i + 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))
+ displayCard(card, i, random_flip)
@cli.command()
@click.argument("state_file", nargs=1, type=click.Path())
@@ -46,18 +50,7 @@ def test(state_file, card_files, scheduler_name, count, random_flip):
session = Session(scheduler_name, card_files, state_file)
for i, (card, correct) in enumerate(session.test(count)):
- click.echo(click.style(f"{i + 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))
- click.echo()
-
+ displayCard(card, i, random_flip)
correct(click.confirm(click.style("Correct?", bold=True)))
if __name__ == '__main__':