]> git.armaanb.net Git - lightcards.git/commitdiff
Implement startup config options
authorArmaan Bhojwani <me@armaanb.net>
Sat, 13 Feb 2021 17:48:30 +0000 (12:48 -0500)
committerArmaan Bhojwani <me@armaanb.net>
Sat, 13 Feb 2021 17:48:30 +0000 (12:48 -0500)
lightcards/runner.py

index 15a622983235a671fd6b330b7efe75a6bd42dc55..73e275875138b93ec7f9edcd05c767b8312dfe45 100644 (file)
@@ -29,7 +29,6 @@ def parse_args():
         metavar="view",
         type=int,
         choices=range(1, 4),
-        default=1,
         help="specify which view to start in (default = 1)",
     )
     parser.add_argument("inp", metavar="input file", type=str, nargs=1)
@@ -76,15 +75,21 @@ def show(args, stack, headers, conf):
         (stack) = cache
 
     # Manipulate deck
-    if args.shuffle:
+    if args.shuffle or conf["shuffle"]:
         shuffle(stack)
-    if args.alphabetize:
+    if args.alphabetize or conf["alphabetize"]:
         stack.sort(key=lambda x: x.front)
-    if args.reverse:
+    if args.reverse or conf["reverse"]:
         stack.reverse()
 
+    # Set view
+    if args.view:
+        view = args.view
+    else:
+        view = conf["default_view"]
+
     # Send to display
-    win = Display(stack, headers, idx, args.view, args, conf)
+    win = Display(stack, headers, idx, view, args, conf)
     try:
         curses.wrapper(win.run)
     except curses.error as e:
@@ -98,9 +103,10 @@ def get_orig():
 
 def main(args=sys.argv):
     args = parse_args()
+    conf = config.read_file(args.config)
+
     global headers, stack
     (headers, stack) = parse.parse_html(parse.md2html(args.inp[0]))
-    conf = config.read_file(args.config)
 
     if not conf["debug"]:
         sys.tracebacklimit = 0