diff --git a/docs/ramalama-version.1.md b/docs/ramalama-version.1.md new file mode 100644 index 00000000..b3a09d47 --- /dev/null +++ b/docs/ramalama-version.1.md @@ -0,0 +1,16 @@ +% ramalama-version 1 + +## NAME +ramalama - Print version of ramalama + +## SYNOPSIS +**ramalama version** + +## DESCRIPTION +Print version of ramalama + +## SEE ALSO +**[ramalama(1)](ramalama.1.md) + +## HISTORY +Aug 2024, Originally compiled by Dan Walsh diff --git a/docs/ramalama.1.md b/docs/ramalama.1.md index 5824284e..6513479d 100644 --- a/docs/ramalama.1.md +++ b/docs/ramalama.1.md @@ -41,6 +41,7 @@ Individual model transports can be modifies when specifying a model via the `hug | [ramalama-push(1)](ramalama-push.1.md) | Push specified AI Model (OCI-only at present) | | [ramalama-run(1)](ramalama-run.1.md) | Run a chatbot on AI Model. | | [ramalama-serve(1)](ramalama-serve.1.md)| Serve local AI Model as an API Service. | +| [ramalama-version(1)](ramalama-version.1.md)| Print ramalama version | ## CONFIGURATION FILES diff --git a/ramalama.py b/ramalama.py index f452651d..7ecf22fe 100755 --- a/ramalama.py +++ b/ramalama.py @@ -21,7 +21,10 @@ def main(args): while len(args) > 0: if args[0] == "-h" or args[0] == "--help": - ramalama.usage() + return ramalama.usage() + + if args[0] == "-v" or args[0] == "version": + return ramalama.version() if args[0] == "--dryrun": args.pop(0) diff --git a/ramalama/__init__.py b/ramalama/__init__.py index 3f171e6e..27ae2523 100644 --- a/ramalama/__init__.py +++ b/ramalama/__init__.py @@ -2,7 +2,7 @@ from ramalama.common import container_manager, exec_cmd, perror from ramalama.cli import create_store, funcDict, usage -from ramalama.version import __version__ +from ramalama.version import version import subprocess import sys import os @@ -12,4 +12,4 @@ __all__ = ['container_manager', 'create_store', 'perror', - 'funcDict', 'usage', '__version__', 'exec_cmd'] + 'funcDict', 'usage', 'exec_cmd', 'version'] diff --git a/ramalama/cli.py b/ramalama/cli.py index e728b4c3..b61c39c6 100644 --- a/ramalama/cli.py +++ b/ramalama/cli.py @@ -13,6 +13,7 @@ from ramalama.huggingface import Huggingface from ramalama.oci import OCI from ramalama.ollama import Ollama +from ramalama.version import version def usage(exit=0): @@ -27,6 +28,7 @@ def usage(exit=0): print(" push MODEL TARGET Push a model to target") print(" run MODEL Run a model") print(" serve MODEL Serve a model") + print(" version Version of ramalama") sys.exit(exit) @@ -234,6 +236,13 @@ def serve_cli(store, args, port): model.serve(store, args) +def version_cli(): + if len(args) > 1: + usage(1) + + version() + + def get_store(): if os.geteuid() == 0: return "/var/lib/ramalama" @@ -256,6 +265,7 @@ def create_store(): funcDict["push"] = push_cli funcDict["run"] = run_cli funcDict["serve"] = serve_cli +funcDict["version"] = version_cli def New(model): diff --git a/ramalama/version.py b/ramalama/version.py index b63024ea..07b309d8 100644 --- a/ramalama/version.py +++ b/ramalama/version.py @@ -1,3 +1,7 @@ """Version of RamalamaPy.""" __version__ = "0.1.0" + + +def version(): + print("ramalama version " + __version__) diff --git a/test/ci.sh b/test/ci.sh index 4a20403d..02bd8729 100755 --- a/test/ci.sh +++ b/test/ci.sh @@ -47,6 +47,7 @@ main() { ./${binfile} -h | grep Usage: set -o pipefail + ./${binfile} version ./${binfile} pull ollama://tinyllama RAMALAMA_TRANSPORT=ollama ./${binfile} pull ben1t0/tiny-llm ./${binfile} pull ollama://tinyllama:1.1b