1 # Markdown flashcard utility
8 from random import shuffle
11 from . import parse, progress
12 from .display import Display, CursesError
13 from .deck import Status
17 """Parse command line arguments"""
18 parser = argparse.ArgumentParser(
19 description="Terminal flashcards from Markdown"
28 help="specify which view to start in (default = 1)",
30 parser.add_argument("inp", metavar="input file", type=str, nargs=1)
35 help="alphabetize card order",
41 help="don't check cached info before starting",
44 "-r", "--reverse", action="store_true", help="reverse card order"
47 "-s", "--shuffle", action="store_true", help="shuffle card order"
53 version=f"lightcards {pkg_resources.require('lightcards')[0].version}",
55 return parser.parse_args()
58 def show(args, stack, headers, input_file):
60 Get objects from cache, manipulate deck according to passed arguments, and
61 send it to the display functions
63 # Purge caches if asked
65 progress.purge(get_orig()[1])
69 cache = progress.dive(get_orig()[1])
77 stack.sort(key=lambda x: x.front)
82 win = Display(stack, headers, idx, args.view, input_file)
84 curses.wrapper(win.run)
85 except curses.error as e:
86 raise CursesError() from e
90 """Return original header and stack"""
91 return (headers, stack)
94 def main(args=sys.argv):
95 sys.tracebacklimit = 0
98 input_file = args.inp[0]
99 (headers, stack) = parse.parse_html(parse.md2html(input_file))
100 show(args, stack, headers, input_file)
103 if __name__ == "__main__":