diff --git a/cllm/main.py b/cllm/main.py index f896750..0b92f1e 100644 --- a/cllm/main.py +++ b/cllm/main.py @@ -3,14 +3,27 @@ import os import json import platform -from langchain.chains import LLMChain +import tomllib from langchain_openai import ChatOpenAI from langchain_core.prompts import (ChatPromptTemplate, FewShotChatMessagePromptTemplate) -app = typer.Typer(help="Empower your CLI experience with a command search tool driven by LLM magic!") +from typing import Optional +from typing_extensions import Annotated + +# version of the CLI +app = typer.Typer(help="Empower your CLI experience with a command search tool driven by LLM magic!", + context_settings={"help_option_names": ["-h", "--help"]} + ) app.add_typer(set_index.set_app, name="set", help="Set up configurations used in cllm") +def version_callback(value: bool): + if value: + with open("./pyproject.toml", "rb") as f: + data = tomllib.load(f) + typer.echo(f"cllm version: {data['tool']['poetry']['version']}") + raise typer.Exit() + @app.command() def search(query : str): """Search a command from the LLM model""" @@ -66,5 +79,11 @@ def search(query : str): typer.echo(output.content) +@app.callback() +def main( + version: Optional[bool] = typer.Option(None, "--version", "-v", callback=version_callback, help="Print cllm version") +): + pass + if __name__ == "__main__": app()