From 94b3ac51583cce0a0df32f7abc657c52762a7a24 Mon Sep 17 00:00:00 2001 From: John Dewey Date: Sat, 14 Mar 2020 14:38:18 -0700 Subject: [PATCH] Allow click to attempt file open Click has error handling when passing a file as a flag. Lets use it. --- gilt/shell.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gilt/shell.py b/gilt/shell.py index 1e4115c..77d2317 100644 --- a/gilt/shell.py +++ b/gilt/shell.py @@ -43,6 +43,7 @@ class NotFoundError(Exception): "--config", default="gilt.yml", help="Path to config file. Default gilt.yml", + type=click.File('r'), ) @click.option( "--debug/--no-debug", @@ -71,7 +72,7 @@ def main(ctx, config, debug): # pragma: no cover ctx.obj = {} ctx.obj["args"] = {} ctx.obj["args"]["debug"] = debug - ctx.obj["args"]["config"] = config + ctx.obj["args"]["config"] = config.name @click.command()