Skip to content

Commit

Permalink
Adds version CLI command (langchain-ai#12619)
Browse files Browse the repository at this point in the history
Will be automatically bumped with `poetry version patch`.

@efriis @hwchase17

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
  • Loading branch information
2 people authored and xieqihui committed Nov 21, 2023
1 parent 4715bb5 commit 4e4fb5f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions libs/cli/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contributing to langchain-cli

Update CLI versions with `poe bump` to ensure that version commands display correctly.
1 change: 1 addition & 0 deletions libs/cli/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ $ langchain [OPTIONS] COMMAND [ARGS]...
**Options**:

* `--help`: Show this message and exit.
* `-v, --version`: Print current CLI version.

**Commands**:

Expand Down
22 changes: 22 additions & 0 deletions libs/cli/langchain_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,35 @@
from langchain_cli.namespaces import app as app_namespace
from langchain_cli.namespaces import template as template_namespace

__version__ = "0.0.11"

app = typer.Typer(no_args_is_help=True, add_completion=False)
app.add_typer(
template_namespace.package_cli, name="template", help=template_namespace.__doc__
)
app.add_typer(app_namespace.app_cli, name="app", help=app_namespace.__doc__)


def version_callback(show_version: bool) -> None:
if show_version:
typer.echo(f"langchain-cli {__version__}")
raise typer.Exit()


@app.callback()
def main(
version: bool = typer.Option(
False,
"--version",
"-v",
help="Print the current CLI version.",
callback=version_callback,
is_eager=True,
),
):
pass


@app.command()
def serve(
*,
Expand Down
8 changes: 7 additions & 1 deletion libs/cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langchain-cli"
version = "0.0.10"
version = "0.0.11"
description = "CLI for interacting with LangChain"
authors = ["Erick Friis <erick@langchain.dev>"]
readme = "README.md"
Expand Down Expand Up @@ -44,9 +44,15 @@ select = [
[tool.poe.tasks]
test = "poetry run pytest"
watch = "poetry run ptw"
version = "poetry version --short"
bump = ["_bump_1", "_bump_2"]
lint = ["_lint", "_check_formatting"]
format = ["_lint_fix", "_format"]

_bump_2.shell = """sed -i "" "/^__version__ =/c\\ \n__version__ = \\"$version\\"\n" langchain_cli/cli.py"""
_bump_2.uses = { version = "version" }

_bump_1 = "poetry version patch"
_check_formatting = "poetry run ruff format . --diff"
_lint = "poetry run ruff ."
_format = "poetry run ruff format ."
Expand Down

0 comments on commit 4e4fb5f

Please sign in to comment.