1 # Markdown flashcard utility
5 from curses import wrapper
8 from random import shuffle
11 from . import parse, progress
12 from .display import Display
13 from .deck import Status
17 """Parse command line arguments"""
18 parser = argparse.ArgumentParser(
19 description="Terminal flashcards from Markdown"
21 parser.add_argument("inp", metavar="input file", type=str, nargs=1)
26 help="alphabetize card order",
32 help="don't check cached info before starting",
35 "-r", "--reverse", action="store_true", help="reverse card order"
38 "-s", "--shuffle", action="store_true", help="shuffle card order"
44 version=f"lightcards {pkg_resources.require('lightcards')[0].version}",
46 return parser.parse_args()
49 def show(args, stack, headers):
51 Get objects from cache, manipulate deck according to passed arguments, and
52 send it to the display functions
54 # Purge caches if asked
60 cache = progress.dive(get_orig()[1])
68 stack.sort(key=lambda x: x.front)
73 win = Display(stack, headers, idx)
78 """Parse arguments and input file again"""
80 os.system(f"$EDITOR {args.inp[0]}"),
81 return parse.parse_html(parse.md2html(args.inp[0]))
85 """Return original header and stack"""
86 return (headers, stack)
89 def main(args=sys.argv):
92 (headers, stack) = parse.parse_html(parse.md2html(args.inp[0]))
93 show(args, stack, headers)
96 if __name__ == "__main__":