Skip to content

Commit

Permalink
cli: add --version option (#2373)
Browse files Browse the repository at this point in the history
- add version option
- add unit test
  • Loading branch information
eyurtsev authored Nov 8, 2024
1 parent 0f92c89 commit f60b9f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions libs/cli/langgraph_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from langgraph_cli.docker import DockerCapabilities
from langgraph_cli.exec import Runner, subp_exec
from langgraph_cli.progress import Progress
from langgraph_cli.version import __version__

OPT_DOCKER_COMPOSE = click.option(
"--docker-compose",
Expand Down Expand Up @@ -148,6 +149,7 @@


@click.group()
@click.version_option(version=__version__, prog_name="LangGraph CLI")
def cli():
pass

Expand Down
18 changes: 17 additions & 1 deletion libs/cli/tests/unit_tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import pathlib

from langgraph_cli.cli import prepare_args_and_stdin
from click.testing import CliRunner

from langgraph_cli.cli import cli, prepare_args_and_stdin
from langgraph_cli.config import Config, validate_config
from langgraph_cli.docker import DEFAULT_POSTGRES_URI, DockerCapabilities, Version
from langgraph_cli.util import clean_empty_lines
Expand Down Expand Up @@ -115,3 +117,17 @@ def test_prepare_args_and_stdin():
"""
assert actual_args == expected_args
assert clean_empty_lines(actual_stdin) == expected_stdin


def test_version_option() -> None:
"""Test the --version option of the CLI."""
runner = CliRunner()
result = runner.invoke(cli, ["--version"])

# Verify that the command executed successfully
assert result.exit_code == 0, "Expected exit code 0 for --version option"

# Check that the output contains the correct version information
assert (
"LangGraph CLI, version" in result.output
), "Expected version information in output"

0 comments on commit f60b9f3

Please sign in to comment.