Skip to content

Commit

Permalink
add: version option to cli (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrai2 authored May 17, 2024
1 parent 058f92c commit 3133989
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
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 @@ -300,6 +300,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

0 comments on commit 3133989

Please sign in to comment.