Skip to content

Commit

Permalink
feat: add --version option to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
kantord committed Jul 28, 2023
1 parent 027f570 commit 6bf15c9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions seagoat/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pygments.lexers.javascript import JavascriptLexer
from pygments.lexers.javascript import TypeScriptLexer

from seagoat import __version__
from seagoat.server import get_server_info_file
from seagoat.server import load_server_info

Expand Down Expand Up @@ -67,6 +68,7 @@ def print_result_line(result, line, color_enabled):
is_flag=True,
help="Disable formatting. Automatically enabled when part of a bash pipeline.",
)
@click.version_option(version=__version__, prog_name="seagoat")
def seagoat(query, repo_path, no_color):
"""
Query your codebase for your QUERY in the Git repository REPO_PATH.
Expand Down
9 changes: 9 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from click.testing import CliRunner

from seagoat import __version__
from seagoat.cli import seagoat
from tests.conftest import pytest

Expand All @@ -24,3 +25,11 @@ def test_integration_test_without_color(snapshot, repo, mocker):

assert result.output == snapshot
assert result.exit_code == 0


def test_version_option():
runner = CliRunner()
result = runner.invoke(seagoat, ["--version"])

assert result.exit_code == 0
assert result.output.strip() == f"seagoat, version {__version__}"

0 comments on commit 6bf15c9

Please sign in to comment.