1 # Markdown flashcard utility
5 from curses import wrapper
7 from random import shuffle
10 from . import parse, progress
11 from .display import Display
12 from .deck import Status
16 """Parse command line arguments"""
17 parser = argparse.ArgumentParser(
18 description="Terminal flashcards from Markdown"
20 parser.add_argument("inp", metavar="input file", type=str, nargs=1)
25 help="alphabetize card order",
28 "-f", "--flip", action="store_true", help="show second column first"
34 help="don't check cached info before starting",
37 "-r", "--reverse", action="store_true", help="reverse card order"
40 "-s", "--shuffle", action="store_true", help="shuffle card order"
43 "-v", "--version", action="version", version="lightcards 0.6.0"
45 return parser.parse_args()
48 def show(args, stack, headers):
50 Get objects from cache, manipulate deck according to passed arguments, and
51 send it to the display functions
53 # Purge caches if asked
59 cache = progress.dive(get_orig()[1])
67 stack.sort(key=lambda x: x.front)
72 x[0], x[1] = x[1], x[0]
73 headers[0], headers[1] = headers[1], headers[0]
76 win = Display(stack, headers, idx)
81 """Parse arguments and input file again"""
83 os.system(f"$EDITOR {args.inp[0]}"),
84 return parse.parse_html(parse.md2html(args.inp[0]))
88 """Return original header and stack"""
89 return (headers, stack)
92 def main(args=sys.argv):
95 (headers, stack) = parse.parse_html(parse.md2html(args.inp[0]))
96 show(args, stack, headers)
99 if __name__ == "__main__":