add in --version flag to cli. closes #1679.

This commit is contained in:
Brandon Hancock
2024-12-03 10:21:58 -05:00
parent 44fc664bde
commit f0e86b5b0f
2 changed files with 12 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ from .update_crew import update_crew
@click.group()
@click.version_option(pkg_resources.get_distribution("crewai").version)
def crewai():
"""Top-level command group for crewai."""
@@ -55,7 +56,10 @@ def create(type, name, provider, skip_provider=False):
)
def version(tools):
"""Show the installed version of crewai."""
crewai_version = pkg_resources.get_distribution("crewai").version
try:
crewai_version = pkg_resources.get_distribution("crewai").version
except Exception:
crewai_version = "unknown version"
click.echo(f"crewai version: {crewai_version}")
if tools:

View File

@@ -131,6 +131,13 @@ def test_reset_no_memory_flags(runner):
)
def test_version_flag(runner):
result = runner.invoke(version)
assert result.exit_code == 0
assert "crewai version:" in result.output
def test_version_command(runner):
result = runner.invoke(version)