diff --git a/bumpversion/aliases.py b/bumpversion/aliases.py index cf35ed2a..08039fd2 100644 --- a/bumpversion/aliases.py +++ b/bumpversion/aliases.py @@ -5,6 +5,8 @@ from click import Context from rich_click.rich_group import RichGroup +from bumpversion.ui import print_warning + class AliasedGroup(RichGroup): """ @@ -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 diff --git a/bumpversion/cli.py b/bumpversion/cli.py index 4d20cfff..aa177767 100644 --- a/bumpversion/cli.py +++ b/bumpversion/cli.py @@ -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__) @@ -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( @@ -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 diff --git a/bumpversion/ui.py b/bumpversion/ui.py index f1d55159..c0bd932a 100644 --- a/bumpversion/ui.py +++ b/bumpversion/ui.py @@ -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")