Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Add a simple --version flag (#5516)

Melroy van den Bergf7bd05ad1325
diff --git a/unsloth_cli/__init__.py b/unsloth_cli/__init__.py
index 28da00f37b8..65834b3b9d8 100644
--- a/unsloth_cli/__init__.py
+++ b/unsloth_cli/__init__.py
@@ -2,17 +2,45 @@
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
import typer
+from importlib.metadata import version as package_version, PackageNotFoundError
+
from unsloth_cli.commands.train import train
from unsloth_cli.commands.inference import inference
from unsloth_cli.commands.export import export, list_checkpoints
from unsloth_cli.commands.studio import run as studio_run, studio_app
+
+def show_version(value: bool):
+ if value:
+ try:
+ version = package_version("unsloth")
+ except PackageNotFoundError:
+ version = "unknown"
+ typer.echo(f"unsloth {version}")
+ raise typer.Exit()
+
+
app = typer.Typer(
help = "Command-line interface for Unsloth training, inference, and export.",
context_settings = {"help_option_names": ["-h", "--help"]},
)
+
+def main(
+ version: bool = typer.Option(
+ None,
+ "--version",
+ "-V",
+ callback = show_version,
+ is_eager = True,
+ help = "Show version and exit.",
+ ),
+):
+ pass
+
+
app.command()(train)
app.command()(inference)
app.command()(export)