Skip to content

Commit

Permalink
Added deprecation warnings
Browse files Browse the repository at this point in the history
- `--list` option will go bye-bye in 1.0
- calling `bumpversion` without a subcomand will leave in 1.0
  • Loading branch information
coordt committed Jul 13, 2023
1 parent 5656c15 commit 733438b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
6 changes: 6 additions & 0 deletions bumpversion/aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from click import Context
from rich_click.rich_group import RichGroup

from bumpversion.ui import print_warning


class AliasedGroup(RichGroup):
"""
Expand Down Expand Up @@ -36,5 +38,9 @@ def resolve_command(self, ctx: Context, args: List[str]) -> tuple:
if cmd.name == "bump" and args != original_args:
if "bump" in original_args:
original_args.remove("bump")
else:
print_warning(
"Calling bumpversion without a subcommand is deprecated. " "Please use `bumpversion bump` instead"
)
return cmd.name, cmd, original_args
return cmd.name, cmd, args
38 changes: 38 additions & 0 deletions bumpversion/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from bumpversion.files import modify_files, resolve_file_config
from bumpversion.logging import setup_logging
from bumpversion.show import do_show, log_list
from bumpversion.ui import print_warning
from bumpversion.utils import get_context, get_overrides

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


click.rich_click.OPTION_GROUPS = {
"bumpversion bump": [
{
"name": "Configuration",
"options": [
"--config-file",
"--current-version",
"--new-version",
"--parse",
"--serialize",
"--search",
"--replace",
"--no-configured-files",
"--ignore-missing-version",
],
},
{
"name": "Output",
"options": ["--dry-run", "--verbose"],
},
{
"name": "Committing and tagging",
"options": [
"--allow-dirty" "--commit",
"--commit-args",
"--message",
"--tag",
"--tag-name",
"--tag-message",
"--sign-tags",
],
},
]
}


@cli.command(context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1, type=str)
@click.option(
Expand Down Expand Up @@ -238,6 +275,7 @@ def bump(
files = args

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

Expand Down
9 changes: 7 additions & 2 deletions bumpversion/ui.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
"""Utilities for user interface."""
from click import UsageError, echo
from click import UsageError, secho


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


def print_error(msg: str) -> None:
"""Raise an error and exit."""
raise UsageError(msg)


def print_warning(msg: str) -> None:
"""Echo a warning to the console."""
secho(f"\nWARNING:\n\n{msg}\n", fg="yellow")

0 comments on commit 733438b

Please sign in to comment.