]> git.armaanb.net Git - lightcards.git/blobdiff - lightcards/lightcards.py
Only cache stack
[lightcards.git] / lightcards / lightcards.py
index ecd18d2cb40043c197758fb42a4c7dd0501eba33..596f89644baffd6ad1b614db52b2e982cfb1e0a5 100644 (file)
@@ -19,12 +19,16 @@ def parse_args():
                         metavar="input file",
                         type=str,
                         nargs=1)
+    parser.add_argument("-a", "--alphabetize",
+                        action='store_true',
+                        help="alphabetize card order")
     parser.add_argument("-f", "--flip",
                         action='store_true',
                         help="show second column first")
     parser.add_argument("-p", "--purge",
                         action='store_true',
                         help="don't check cached info before starting")
+    # TODO: don't require input file when using  -P
     parser.add_argument("-P", "--purge-all",
                         action='store_true',
                         help="don't check cached info before starting")
@@ -52,29 +56,22 @@ def show(args, stack, headers):
         progress.purge_all()
 
     # Check for caches
-    ida = progress.dive("status", stack)
-    if ida:
-        idx = ida
-    else:
-        idx = Status()
-
-    stackb = progress.dive("stack", stack)
-    if stackb:
-        stack = stackb
-
-    headerb = progress.dive("headers", stack)
-    if headerb:
-        headers = headerb
+    idx = Status()
+    cache = progress.dive(get_orig())
+    if cache:
+        (stack) = cache
 
     # Manipulate deck
-    if args.flip:
-        for x in stack:
-            x[0], x[1] = x[1], x[0]
-        headers[0], headers[1] = headers[1], headers[0]
     if args.shuffle:
         shuffle(stack)
+    if args.alphabetize:
+        stack.sort()
     if args.reverse:
         stack.reverse()
+    if args.flip:
+        for x in stack:
+            x[0], x[1] = x[1], x[0]
+        headers[0], headers[1] = headers[1], headers[0]
 
     # Send to display
     win = Display(stack, headers, idx)