]> git.armaanb.net Git - lightcards.git/blobdiff - lightcards/lightcards.py
Bump version number
[lightcards.git] / lightcards / lightcards.py
index a996ccc8a46ab9aa315ab01ab4b287534bdbedca..00681120492cb7d3178996559c40ff597697e07c 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")
@@ -36,43 +40,40 @@ def parse_args():
                         help="shuffle card order")
     parser.add_argument("-v", "--version",
                         action='version',
-                        version="lightcards 0.4.0")
+                        version="lightcards 0.5.0")
     return parser.parse_args()
 
 
 def show(args, stack, headers):
     """
-    Manipulate deck according to passed arguments, and send it to the display
-    functions
+    Get objects from cache, manipulate deck according to passed arguments, and
+    send it to the display functions
     """
+    # Purge caches if asked
     if args.purge:
         progress.purge(stack)
     if args.purge_all:
         progress.purge_all()
 
-    ida = progress.dive("status", stack)
-    if ida and not args.purge:
-        idx = ida
-    else:
-        idx = Status()
-
-    stackb = progress.dive("stack", stack)
-    if stackb and not args.purge:
-        stack = stackb
-
-    headerb = progress.dive("headers", stack)
-    if headerb and not args.purge:
-        headers = headerb
+    # Check for caches
+    idx = Status()
+    cache = progress.dive(get_orig())
+    if cache:
+        (stack) = cache
 
-    if args.flip:
-        for x in stack:
-            x[0], x[1] = x[1], x[0]
-        headers[0], headers[1] = headers[1], headers[0]
+    # Manipulate deck
     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)
     wrapper(win.run)