summaryrefslogtreecommitdiffstats
path: root/src/flashcard_cli.py
blob: 9e9633d7639491dcff2e39081c8c5d78bf7f9cba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import click
from json import load
from os.path import isfile

from card import Card
from scheduler import getSchedulerClass, SCHEDULERS
from parser import parseFiles


@click.group()
def cli():
    pass

@cli.command()
@click.option("--scheduler", "scheduler_name", default="brutal", type=click.Choice(SCHEDULERS, case_sensitive=False))
@click.argument("state_file", nargs=1, type=click.Path())
@click.argument("card_files", nargs=-1, type=click.Path(exists=True))
def practice(scheduler_name, state_file, card_files):
    """
    Run a practice session with the specified scheduler, using the provided state and card files.
    """
    cards = parseFiles(card_files)
    state = json.load(state_file) if isfile(state_file) else {}

    scheduler = getSchedulerClass(scheduler_name)(cards, state)
    




if __name__ == '__main__':
    cli()