Skip to content
Open
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
5 changes: 5 additions & 0 deletions cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ def _hoist_global_options(args: list[str]) -> list[str]:


@click.group(help=_HELP)
@click.version_option(
version=None,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tough. we can set it here and control when we do releases?

In a compiled-binary-world, the version can be 'baked' into the build. But for python, there's no real "build" step is there?

package_name="allium-cli",
prog_name="allium",
)
@click.option(
"--profile",
default=None,
Expand Down
19 changes: 18 additions & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations

from cli.main import _hoist_global_options
from click.testing import CliRunner

from cli.main import _hoist_global_options, cli


class TestHoistGlobalOptions:
Expand Down Expand Up @@ -46,3 +48,18 @@ def test_verbose_long_form(self):
args = ["auth", "list", "--verbose"]
result = _hoist_global_options(args)
assert result[0] == "--verbose"


class TestVersionFlag:
def test_version_flag_outputs_version(self):
runner = CliRunner()
result = runner.invoke(cli, ["--version"])
assert result.exit_code == 0
assert "allium" in result.output.lower()

def test_version_flag_contains_version_number(self):
runner = CliRunner()
result = runner.invoke(cli, ["--version"])
assert result.exit_code == 0
# Version output should contain a semver-like pattern
assert "." in result.output
Loading