diff --git a/README.md b/README.md index 6e4b12b..9a77d62 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ To install `gnucash to beancount` simply use `pip`: pip install g2b ``` +Test with `g2b --version` if the installation was successful. + ## Usage ### Create Configuration for g2b diff --git a/g2b/g2b.py b/g2b/g2b.py index 7d71344..62f3478 100644 --- a/g2b/g2b.py +++ b/g2b/g2b.py @@ -299,6 +299,7 @@ def _get_open_account_directives(self, transactions): @click.command() +@click.version_option(message="%(version)s") @click.option( "--input", "-i", diff --git a/tests/test_g2b.py b/tests/test_g2b.py index ffa5c95..fe78822 100644 --- a/tests/test_g2b.py +++ b/tests/test_g2b.py @@ -3,6 +3,7 @@ # pylint: disable=protected-access import datetime import re +from importlib.metadata import version from pathlib import Path, PosixPath from unittest import mock @@ -52,6 +53,11 @@ def test_cli_raises_on_non_existing_config_file(self, tmp_path): r".*Path 'test_config.yml' does not exist.*", result.output, flags=re.DOTALL ) + def test_cli_version(self): + result = self.cli_runner.invoke(main, "--version") + assert result.exit_code == 0, f"{result.exc_info}" + assert version("g2b") in result.output + class TestGnuCash2Beancount: