From fc9a384801c881d60fe3df25503c6a0245eb21f9 Mon Sep 17 00:00:00 2001 From: Todd Wolfson Date: Wed, 23 Feb 2022 21:46:37 -0800 Subject: [PATCH] Added fix for missing filepath, fixes #58 --- restructuredtext_lint/cli.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/restructuredtext_lint/cli.py b/restructuredtext_lint/cli.py index 9dd1a72..4439c91 100644 --- a/restructuredtext_lint/cli.py +++ b/restructuredtext_lint/cli.py @@ -43,12 +43,16 @@ def _main(paths, format=DEFAULT_FORMAT, stream=sys.stdout, encoding=None, level= # Check if the given path is a file or a directory if os.path.isfile(path): filepaths.append(path) - else: + elif os.path.isdir(path): # Recurse over subdirectories to search for *.rst files for root, subdir, files in os.walk(path): for file in files: if file.endswith('.rst'): filepaths.append(os.path.join(root, file)) + else: + stream.write('Path "{path}" not found as a file nor directory\n'.format(path=path)) + sys.exit(1) + return for filepath in filepaths: # Read and lint the file