From c1b542b2b1b6db3e48d8223b8588f743251d6113 Mon Sep 17 00:00:00 2001 From: LucasLvy Date: Tue, 9 Aug 2022 12:16:52 +0200 Subject: [PATCH] feat(cli): check if file is specified and exists --- amarna/command_line.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/amarna/command_line.py b/amarna/command_line.py index 3920c13..e1ed6bc 100644 --- a/amarna/command_line.py +++ b/amarna/command_line.py @@ -96,7 +96,7 @@ def main() -> int: metavar="-f", type=str, help="the name of the .cairo file or directory with .cairo files to analyze", - nargs="?" + nargs="?", ) parser.add_argument("-p", "--print", action="store_true", help="print output") @@ -150,9 +150,12 @@ def main() -> int: filename = args.filename - if not os.path.isabs(filename): + if filename is not None and not os.path.isabs(filename): filename = os.path.join(os.getcwd(), filename) + if not os.path.exists(filename): + raise Exception("The specified file doesn't exist") + rule_set_names: List[str] = get_rule_names(args.rules, args.exclude_rules) results: List[Union[Result, ResultMultiplePositions]]