Skip to content

Commit 733438b

Browse files
committed
Added deprecation warnings
- `--list` option will go bye-bye in 1.0 - calling `bumpversion` without a subcomand will leave in 1.0
1 parent 5656c15 commit 733438b

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

bumpversion/aliases.py

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from click import Context
66
from rich_click.rich_group import RichGroup
77

8+
from bumpversion.ui import print_warning
9+
810

911
class AliasedGroup(RichGroup):
1012
"""
@@ -36,5 +38,9 @@ def resolve_command(self, ctx: Context, args: List[str]) -> tuple:
3638
if cmd.name == "bump" and args != original_args:
3739
if "bump" in original_args:
3840
original_args.remove("bump")
41+
else:
42+
print_warning(
43+
"Calling bumpversion without a subcommand is deprecated. " "Please use `bumpversion bump` instead"
44+
)
3945
return cmd.name, cmd, original_args
4046
return cmd.name, cmd, args

bumpversion/cli.py

+38
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from bumpversion.files import modify_files, resolve_file_config
1313
from bumpversion.logging import setup_logging
1414
from bumpversion.show import do_show, log_list
15+
from bumpversion.ui import print_warning
1516
from bumpversion.utils import get_context, get_overrides
1617

1718
logger = logging.getLogger(__name__)
@@ -34,6 +35,42 @@ def cli(ctx: Context) -> None:
3435
ctx.invoke(bump, *ctx.args)
3536

3637

38+
click.rich_click.OPTION_GROUPS = {
39+
"bumpversion bump": [
40+
{
41+
"name": "Configuration",
42+
"options": [
43+
"--config-file",
44+
"--current-version",
45+
"--new-version",
46+
"--parse",
47+
"--serialize",
48+
"--search",
49+
"--replace",
50+
"--no-configured-files",
51+
"--ignore-missing-version",
52+
],
53+
},
54+
{
55+
"name": "Output",
56+
"options": ["--dry-run", "--verbose"],
57+
},
58+
{
59+
"name": "Committing and tagging",
60+
"options": [
61+
"--allow-dirty" "--commit",
62+
"--commit-args",
63+
"--message",
64+
"--tag",
65+
"--tag-name",
66+
"--tag-message",
67+
"--sign-tags",
68+
],
69+
},
70+
]
71+
}
72+
73+
3774
@cli.command(context_settings={"ignore_unknown_options": True})
3875
@click.argument("args", nargs=-1, type=str)
3976
@click.option(
@@ -238,6 +275,7 @@ def bump(
238275
files = args
239276

240277
if show_list:
278+
print_warning("DEPRECATED: The --list option is deprecated and will be removed in a future version.")
241279
log_list(config, version_part, new_version)
242280
return
243281

bumpversion/ui.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
"""Utilities for user interface."""
2-
from click import UsageError, echo
2+
from click import UsageError, secho
33

44

55
def print_info(msg: str) -> None:
66
"""Echo a message to the console."""
7-
echo(msg)
7+
secho(msg)
88

99

1010
def print_error(msg: str) -> None:
1111
"""Raise an error and exit."""
1212
raise UsageError(msg)
13+
14+
15+
def print_warning(msg: str) -> None:
16+
"""Echo a warning to the console."""
17+
secho(f"\nWARNING:\n\n{msg}\n", fg="yellow")

0 commit comments

Comments
 (0)