Skip to content

Commit 878197f

Browse files
committed
Add support for specifying current version in do_show
This update introduces a `--current-version` option to the `show` command and passes it into the `do_show` function. If provided, the `current_version` is added to the configuration, allowing more control over version display or manipulation.
1 parent af83814 commit 878197f

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

bumpversion/cli.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,16 @@ def bump(
337337
type=str,
338338
help="Increment the version component and add `new_version` to the configuration.",
339339
)
340-
def show(args: List[str], config_file: Optional[str], format_: str, increment: Optional[str]) -> None:
340+
@click.option(
341+
"--current-version",
342+
metavar="VERSION",
343+
required=False,
344+
envvar="BUMPVERSION_CURRENT_VERSION",
345+
help="Version that needs to be updated",
346+
)
347+
def show(
348+
args: List[str], config_file: Optional[str], format_: str, increment: Optional[str], current_version: Optional[str]
349+
) -> None:
341350
"""
342351
Show current configuration information.
343352
@@ -355,9 +364,9 @@ def show(args: List[str], config_file: Optional[str], format_: str, increment: O
355364
config = get_configuration(found_config_file)
356365

357366
if not args:
358-
do_show("all", config=config, format_=format_, increment=increment)
367+
do_show("all", config=config, format_=format_, increment=increment, current_version=current_version)
359368
else:
360-
do_show(*args, config=config, format_=format_, increment=increment)
369+
do_show(*args, config=config, format_=format_, increment=increment, current_version=current_version)
361370

362371

363372
@cli.command()

bumpversion/show.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,16 @@ def resolve_name(obj: Any, name: str, default: Any = None, err_on_missing: bool
114114
return default
115115

116116

117-
def do_show(*args, config: Config, format_: str = "default", increment: Optional[str] = None) -> None:
117+
def do_show(
118+
*args,
119+
config: Config,
120+
format_: str = "default",
121+
increment: Optional[str] = None,
122+
current_version: Optional[str] = None,
123+
) -> None:
118124
"""Show current version or configuration information."""
125+
if current_version:
126+
config.current_version = current_version
119127
config_dict = config.model_dump()
120128
ctx = get_context(config)
121129

0 commit comments

Comments
 (0)