From 5dad89972f6ae6f00cc1ce2f05298bdc38a8712b Mon Sep 17 00:00:00 2001 From: Nour El Mawass Date: Thu, 9 Feb 2023 18:26:54 +0100 Subject: [PATCH] Add the `--version` option to the CLI --- fawltydeps/main.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fawltydeps/main.py b/fawltydeps/main.py index 852f45d7..451822f1 100644 --- a/fawltydeps/main.py +++ b/fawltydeps/main.py @@ -9,6 +9,8 @@ from pathlib import Path from typing import List, Optional, Set, TextIO +import pkg_resources + from fawltydeps import extract_imports from fawltydeps.check import compare_imports_to_dependencies from fawltydeps.extract_declared_dependencies import extract_declared_dependencies @@ -132,6 +134,13 @@ def main() -> int: const={Action.REPORT_UNDECLARED, Action.REPORT_UNUSED}, help="Report both undeclared and unused dependencies", ) + parser.add_argument( + "-V", + "--version", + action="version", + version=f"Fawltydeps {pkg_resources.get_distribution('fawltydeps').version}", + help=("Print the version number of fawltydeps"), + ) select_action.add_argument( "--check-undeclared", dest="actions",