Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: version option to cli #5

Merged
merged 2 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions g2b/g2b.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ def _get_open_account_directives(self, transactions):


@click.command()
@click.version_option(message="%(version)s")
@click.option(
"--input",
"-i",
Expand Down
6 changes: 6 additions & 0 deletions tests/test_g2b.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:

Expand Down