From: Armaan Bhojwani Date: Sat, 13 Feb 2021 22:59:48 +0000 (-0500) Subject: Exit if specified config file does not exist X-Git-Tag: v0.7.0~17 X-Git-Url: http://git.armaanb.net/zpe/tree/?p=lightcards.git;a=commitdiff_plain;h=2203afc601a1a16f299bb8e3691a57e45c8230fc Exit if specified config file does not exist --- diff --git a/lightcards/config.py b/lightcards/config.py index 2b8b938..04cfdf9 100644 --- a/lightcards/config.py +++ b/lightcards/config.py @@ -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) diff --git a/lightcards/runner.py b/lightcards/runner.py index 3b8737c..852bf5b 100644 --- a/lightcards/runner.py +++ b/lightcards/runner.py @@ -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(