From 7067963d6e60495480994ebb8c7b50922a14d5ea Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Tue, 14 Apr 2026 23:59:35 +0200 Subject: [PATCH] Support `serena --version` CLI command Resolves #1347 --- CHANGELOG.md | 3 +++ src/serena/cli.py | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddbdc6b1..768f6260 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ Status of the `main` branch. Changes prior to the next official version change will appear here. +* General: + - Support `serena --version` CLI command for displaying the current version #1347 + # v1.1.2 (2026-04-14) * General: diff --git a/src/serena/cli.py b/src/serena/cli.py index 84f2fcc9..a82ba180 100644 --- a/src/serena/cli.py +++ b/src/serena/cli.py @@ -139,6 +139,26 @@ class TopLevelCommands(AutoRegisteringGroup): "that separate entrypoint for performance reasons, see `serena-hooks --help`. You can run ` --help` for more info on each command.", ) + # register --version / -V flag + self.params.append( + click.Option( + ["--version", "-V"], + is_flag=True, + expose_value=False, + is_eager=True, + callback=self._print_version, + help="Show the version and exit.", + ) + ) + + @staticmethod + def _print_version(ctx: click.Context, _param: click.Parameter, value: bool) -> None: + """Print version string and exit if the flag is set.""" + if not value: + return + click.echo(f"Serena {serena_version()}") + ctx.exit() + @staticmethod @click.command( "init",