]> git.armaanb.net Git - lightcards.git/commitdiff
Exit if specified config file does not exist
authorArmaan Bhojwani <me@armaanb.net>
Sat, 13 Feb 2021 22:59:48 +0000 (17:59 -0500)
committerArmaan Bhojwani <me@armaanb.net>
Sat, 13 Feb 2021 23:48:29 +0000 (18:48 -0500)
lightcards/config.py
lightcards/runner.py

index 2b8b93880d6707e15f958507200338b1ab211d8a..04cfdf99627f108ccc12fafb0d0506d3c194d919 100644 (file)
@@ -27,8 +27,10 @@ def read_file(file):
         files.append(local_xdg)
     if os.path.exists(local):
         files.append(local)
-    if os.path.exists(file):
-        files.append(file)
+
+    files.append(file)
+    if not os.path.exists(file):
+        raise ConfigException(f'"{file}": No such file or directory') from None
 
     for f in files:
         exec(Path(str(f)).read_text(), {}, config)
index 3b8737cab801bfe3ec5c46e53a06cd98a9f123ca..852bf5bf64b8c921e832aae4541554b87fc48f67 100644 (file)
@@ -20,7 +20,9 @@ def parse_args():
     parser.add_argument(
         "-c",
         "--config",
+        metavar="path",
         type=str,
+        default="/dev/null",
         help="specify custom config file",
     )
     parser.add_argument(
@@ -29,7 +31,7 @@ def parse_args():
         metavar="view",
         type=int,
         choices=range(1, 4),
-        help="specify which view to start in (default = 1)",
+        help="specify which view to start in",
     )
     parser.add_argument("inp", metavar="input file", type=str, nargs=1)
     parser.add_argument(