Skip to content

Commit 7067963

Browse files
committed
Support serena --version CLI command
Resolves #1347
1 parent d6ea5bf commit 7067963

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
Status of the `main` branch. Changes prior to the next official version change will appear here.
44

5+
* General:
6+
- Support `serena --version` CLI command for displaying the current version #1347
7+
58
# v1.1.2 (2026-04-14)
69

710
* General:

src/serena/cli.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,26 @@ def __init__(self) -> None:
139139
"that separate entrypoint for performance reasons, see `serena-hooks --help`. You can run `<command> --help` for more info on each command.",
140140
)
141141

142+
# register --version / -V flag
143+
self.params.append(
144+
click.Option(
145+
["--version", "-V"],
146+
is_flag=True,
147+
expose_value=False,
148+
is_eager=True,
149+
callback=self._print_version,
150+
help="Show the version and exit.",
151+
)
152+
)
153+
154+
@staticmethod
155+
def _print_version(ctx: click.Context, _param: click.Parameter, value: bool) -> None:
156+
"""Print version string and exit if the flag is set."""
157+
if not value:
158+
return
159+
click.echo(f"Serena {serena_version()}")
160+
ctx.exit()
161+
142162
@staticmethod
143163
@click.command(
144164
"init",

0 commit comments

Comments
 (0)