diff --git a/README.md b/README.md index 264388e..8addb93 100644 --- a/README.md +++ b/README.md @@ -71,8 +71,9 @@ Options: --help Show this message and exit. Commands: - config The config command is used to create a default config file. - run The run command is the main command for the tool. + config The config command is used to create a default config file. + run The run command is the main command for the tool. + version Prints the version of the tool. ``` The most basic usage to retrieve all information is: diff --git a/src/main.py b/src/main.py index 74331ec..713a176 100644 --- a/src/main.py +++ b/src/main.py @@ -1,6 +1,3 @@ -import platform -import time - import click from src.constants import CONFIG_PATH_DEFAULT @@ -14,7 +11,7 @@ from src.core.processes import print_cpu_usage_info, print_memory_usage_info from src.core.services import print_process_info from src.core.system import print_system_info -from src.utilities.utils import print_title_red + DISPATCH = { "all": lambda config: print_all_info(config), @@ -44,6 +41,21 @@ def cli(): """System information tool.""" +# The version command +@cli.command(name="version") +def print_version(): + """Prints the version of the tool.""" + # version = pkg_resources.get_distribution('python-sysinformer').version + # use importlib.resources to get the version + try: + from importlib.metadata import version # pylint: disable=import-outside-toplevel + + psi_version = version("python-sysinformer") + print(f"psi version {psi_version}") + except ImportError: + print("importlib.metadata not found") + + @cli.command(name="run") @click.option("-a", "--all", is_flag=True, help="Show all information") @click.option("-s", "--system", is_flag=True, help="Show only system information")