Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/click/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@ def version_option(
:param prog_name: The name of the CLI to show in the message. If not
provided, it will be detected from the command.
:param message: The message to show. The values ``%(prog)s``,
``%(package)s``, and ``%(version)s`` are available. Defaults to
``"%(prog)s, version %(version)s"``.
``%(package)s``, ``%(version)s`` and ``%(python_version)`` are
available. Defaults to ``"%(prog)s, version %(version)s"``.
:param kwargs: Extra arguments are passed to :func:`option`.
:raise RuntimeError: ``version`` could not be detected.

Expand Down Expand Up @@ -514,9 +514,17 @@ def callback(ctx: Context, param: Parameter, value: bool) -> None:
raise RuntimeError(
f"Could not determine the version for {package_name!r} automatically."
)
import platform

python_version = platform.python_version()
echo(
message % {"prog": prog_name, "package": package_name, "version": version},
message
% {
"prog": prog_name,
"package": package_name,
"version": version,
"python_version": python_version,
},
color=ctx.color,
)
ctx.exit()
Expand Down