diff options
| -rwxr-xr-x | nemesis/nemesis.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/nemesis/nemesis.py b/nemesis/nemesis.py index e7c5e7e..c1a6fb2 100755 --- a/nemesis/nemesis.py +++ b/nemesis/nemesis.py @@ -340,6 +340,11 @@ def validate_dir(path_str: str) -> Path: raise ValueError(f"Can't profile a non-dir: {p}") return p +def validate_html(filename: str) -> str: + if not filename.lower().endswith('.html'): + raise argparse.ArgumentTypeError(f"Did not name an HTML file: '{filename}'") + return filename + if __name__ == "__main__": # parses CLI arguments and facilitates profiler runtime. parser = argparse.ArgumentParser( @@ -358,20 +363,20 @@ if __name__ == "__main__": type=float, default=3) parser.add_argument('-f', '--filename', - help='The filename to write results to.', + help='The filename to write results to. Must name an HTML file.', metavar='', - type=str, + type=validate_html, default="results.html") - # parser.add_argument('--include-paths', - # help='Specify the path(s) containing files to profile. If a file is in this path, it is a candidate for optimization.', - # nargs="+", - # type=validate_dir, - # required=True) - # parser.add_argument('--exclude-paths', - # help='Specify the path(s) containing files to exclude profile. Takes priority over --include-paths.', - # nargs="*", - # type=validate_dir, - # required=False) + parser.add_argument('--include-paths', + help='Specify the path(s) containing files to profile. If a file is in this path, it is a candidate for optimization.', + nargs="+", + type=validate_dir, + required=True) + parser.add_argument('--exclude-paths', + help='Specify the path(s) containing files to exclude profile. Takes priority over --include-paths.', + nargs="*", + type=validate_dir, + required=False) parser.add_argument('prog', type=str, nargs='*', |
