Skip to content

Commit e56c944

Browse files
committed
Removes ability to call the CLI without subcommand
BREAKING CHANGE: You must use bump-my-version bump
1 parent e13b0f0 commit e56c944

File tree

4 files changed

+3
-181
lines changed

4 files changed

+3
-181
lines changed

bumpversion/cli.py

+3-19
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,20 @@
99
from tomlkit import dumps
1010

1111
from bumpversion import __version__
12-
from bumpversion.aliases import AliasedGroup
1312
from bumpversion.bump import do_bump
1413
from bumpversion.config import get_configuration
1514
from bumpversion.config.create import create_configuration
1615
from bumpversion.config.files import find_config_file
1716
from bumpversion.files import ConfiguredFile, modify_files
18-
from bumpversion.show import do_show, log_list
19-
from bumpversion.ui import get_indented_logger, print_info, print_warning, setup_logging
17+
from bumpversion.show import do_show
18+
from bumpversion.ui import get_indented_logger, print_info, setup_logging
2019
from bumpversion.utils import get_context, get_overrides
2120
from bumpversion.visualize import visualize
2221

2322
logger = get_indented_logger(__name__)
2423

2524

2625
@click.group(
27-
cls=AliasedGroup,
28-
invoke_without_command=True,
2926
context_settings={
3027
"ignore_unknown_options": True,
3128
"allow_interspersed_args": True,
@@ -37,8 +34,7 @@
3734
@click.pass_context
3835
def cli(ctx: Context) -> None:
3936
"""Version bump your Python project."""
40-
if ctx.invoked_subcommand is None:
41-
ctx.invoke(bump, *ctx.args)
37+
pass
4238

4339

4440
click.rich_click.OPTION_GROUPS = {
@@ -228,12 +224,6 @@ def cli(ctx: Context) -> None:
228224
envvar="BUMPVERSION_COMMIT_ARGS",
229225
help="Extra arguments to commit command",
230226
)
231-
@click.option(
232-
"--list",
233-
"show_list",
234-
is_flag=True,
235-
help="List machine readable information",
236-
)
237227
def bump(
238228
# version_part: str,
239229
args: list,
@@ -258,7 +248,6 @@ def bump(
258248
tag_message: Optional[str],
259249
message: Optional[str],
260250
commit_args: Optional[str],
261-
show_list: bool,
262251
) -> None:
263252
"""
264253
Change the version.
@@ -306,11 +295,6 @@ def bump(
306295
version_part = None
307296
files = args
308297

309-
if show_list:
310-
print_warning("DEPRECATED: The --list option is deprecated and will be removed in a future version.")
311-
log_list(config, version_part, new_version)
312-
return
313-
314298
config.allow_dirty = allow_dirty if allow_dirty is not None else config.allow_dirty
315299
if not config.allow_dirty and config.scm_info.tool:
316300
config.scm_info.tool.assert_nondirty()

bumpversion/show.py

-15
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,6 @@ def resolve_name(obj: Any, name: str, default: Any = None, err_on_missing: bool
108108
return default
109109

110110

111-
def log_list(config: Config, version_part: Optional[str], new_version: Optional[str]) -> None:
112-
"""Output configuration with new version."""
113-
ctx = get_context(config)
114-
if version_part:
115-
version = config.version_config.parse(config.current_version)
116-
next_version = get_next_version(version, config, version_part, new_version)
117-
next_version_str = config.version_config.serialize(next_version, ctx)
118-
119-
print_info(f"new_version={next_version_str}")
120-
121-
config_dict = recursive_sort_dict(config.model_dump(exclude={"scm_info", "parts"}))
122-
for key, value in config_dict.items():
123-
print_info(f"{key}={value}")
124-
125-
126111
def do_show(*args, config: Config, format_: str = "default", increment: Optional[str] = None) -> None:
127112
"""Show current version or configuration information."""
128113
config_dict = config.model_dump()

tests/test_cli/test_bump.py

-125
Original file line numberDiff line numberDiff line change
@@ -59,131 +59,6 @@ def test_file_args_marked_to_modify(self, mocker, tmp_path: Path):
5959
assert passed_config.files[0].filename == "do-this-file.txt"
6060

6161

62-
class TestListOption:
63-
"""Test the deprecated --list option."""
64-
65-
def test_with_version_part_includes_new_version(self, tmp_path: Path, fixtures_path: Path):
66-
"""The --list option should list the configuration with new_version."""
67-
# Arrange
68-
config_path = tmp_path / "pyproject.toml"
69-
toml_path = fixtures_path / "basic_cfg.toml"
70-
shutil.copy(toml_path, config_path)
71-
runner: CliRunner = CliRunner()
72-
73-
with inside_dir(tmp_path):
74-
result: Result = runner.invoke(cli.cli, ["bump", "--list", "patch"])
75-
76-
if result.exit_code != 0:
77-
print(result.output)
78-
print(result.exception)
79-
80-
assert result.exit_code == 0
81-
assert set(result.output.splitlines(keepends=False)) == {
82-
"WARNING:",
83-
"",
84-
"DEPRECATED: The --list option is deprecated and will be removed in a future version.",
85-
"new_version=1.0.1-dev",
86-
"current_version=1.0.0",
87-
"excluded_paths=[]",
88-
"parse=(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)(\\-(?P<release>[a-z]+))?",
89-
"serialize=('{major}.{minor}.{patch}-{release}', '{major}.{minor}.{patch}')",
90-
"search={current_version}",
91-
"replace={new_version}",
92-
"regex=False",
93-
"ignore_missing_files=False",
94-
"ignore_missing_version=False",
95-
"included_paths=[]",
96-
"tag=True",
97-
"sign_tags=False",
98-
"tag_name=v{new_version}",
99-
"tag_message=Bump version: {current_version} → {new_version}",
100-
"allow_dirty=False",
101-
"commit=True",
102-
"message=Bump version: {current_version} → {new_version}",
103-
"commit_args=None",
104-
(
105-
"files=[{'parse': "
106-
"'(?P<major>\\\\d+)\\\\.(?P<minor>\\\\d+)\\\\.(?P<patch>\\\\d+)(\\\\-(?P<release>[a-z]+))?', "
107-
"'serialize': ('{major}.{minor}.{patch}-{release}', "
108-
"'{major}.{minor}.{patch}'), 'search': '{current_version}', 'replace': "
109-
"'{new_version}', 'regex': False, 'ignore_missing_version': False, "
110-
"'ignore_missing_file': False, 'filename': 'setup.py', 'glob': None, 'key_path': None}, {'parse': "
111-
"'(?P<major>\\\\d+)\\\\.(?P<minor>\\\\d+)\\\\.(?P<patch>\\\\d+)(\\\\-(?P<release>[a-z]+))?', "
112-
"'serialize': ('{major}.{minor}.{patch}-{release}', "
113-
"'{major}.{minor}.{patch}'), 'search': '{current_version}', 'replace': "
114-
"'{new_version}', 'regex': False, 'ignore_missing_version': False, "
115-
"'ignore_missing_file': False, 'filename': 'bumpversion/__init__.py', 'glob': None, 'key_path': None}, "
116-
"{'parse': "
117-
"'(?P<major>\\\\d+)\\\\.(?P<minor>\\\\d+)\\\\.(?P<patch>\\\\d+)(\\\\-(?P<release>[a-z]+))?', "
118-
"'serialize': ('{major}.{minor}.{patch}-{release}', "
119-
"'{major}.{minor}.{patch}'), 'search': '**unreleased**', 'replace': "
120-
"'**unreleased**\\n**v{new_version}**', 'regex': False, "
121-
"'ignore_missing_version': False, 'ignore_missing_file': False, 'filename': 'CHANGELOG.md', "
122-
"'glob': None, 'key_path': None}]"
123-
),
124-
}
125-
126-
def test_without_version_part_excludes_new_version(self, tmp_path: Path, fixtures_path: Path):
127-
"""The --list option should list the configuration without new_version."""
128-
# Arrange
129-
config_path = tmp_path / "pyproject.toml"
130-
toml_path = fixtures_path / "basic_cfg.toml"
131-
shutil.copy(toml_path, config_path)
132-
runner: CliRunner = CliRunner()
133-
134-
with inside_dir(tmp_path):
135-
result: Result = runner.invoke(cli.cli, ["bump", "--list"])
136-
137-
if result.exit_code != 0:
138-
print(result.output)
139-
print(result.exception)
140-
141-
assert result.exit_code == 0
142-
assert set(result.output.splitlines(keepends=False)) == {
143-
"WARNING:",
144-
"",
145-
"DEPRECATED: The --list option is deprecated and will be removed in a future version.",
146-
"current_version=1.0.0",
147-
"excluded_paths=[]",
148-
"parse=(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)(\\-(?P<release>[a-z]+))?",
149-
"serialize=('{major}.{minor}.{patch}-{release}', '{major}.{minor}.{patch}')",
150-
"search={current_version}",
151-
"replace={new_version}",
152-
"regex=False",
153-
"ignore_missing_files=False",
154-
"ignore_missing_version=False",
155-
"included_paths=[]",
156-
"tag=True",
157-
"sign_tags=False",
158-
"tag_name=v{new_version}",
159-
"tag_message=Bump version: {current_version} → {new_version}",
160-
"allow_dirty=False",
161-
"commit=True",
162-
"message=Bump version: {current_version} → {new_version}",
163-
"commit_args=None",
164-
(
165-
"files=[{'parse': "
166-
"'(?P<major>\\\\d+)\\\\.(?P<minor>\\\\d+)\\\\.(?P<patch>\\\\d+)(\\\\-(?P<release>[a-z]+))?', "
167-
"'serialize': ('{major}.{minor}.{patch}-{release}', "
168-
"'{major}.{minor}.{patch}'), 'search': '{current_version}', 'replace': "
169-
"'{new_version}', 'regex': False, 'ignore_missing_version': False, "
170-
"'ignore_missing_file': False, 'filename': 'setup.py', 'glob': None, 'key_path': None}, {'parse': "
171-
"'(?P<major>\\\\d+)\\\\.(?P<minor>\\\\d+)\\\\.(?P<patch>\\\\d+)(\\\\-(?P<release>[a-z]+))?', "
172-
"'serialize': ('{major}.{minor}.{patch}-{release}', "
173-
"'{major}.{minor}.{patch}'), 'search': '{current_version}', 'replace': "
174-
"'{new_version}', 'regex': False, 'ignore_missing_version': False, "
175-
"'ignore_missing_file': False, 'filename': 'bumpversion/__init__.py', 'glob': None, 'key_path': None}, "
176-
"{'parse': "
177-
"'(?P<major>\\\\d+)\\\\.(?P<minor>\\\\d+)\\\\.(?P<patch>\\\\d+)(\\\\-(?P<release>[a-z]+))?', "
178-
"'serialize': ('{major}.{minor}.{patch}-{release}', "
179-
"'{major}.{minor}.{patch}'), 'search': '**unreleased**', 'replace': "
180-
"'**unreleased**\\n**v{new_version}**', 'regex': False, "
181-
"'ignore_missing_version': False, 'ignore_missing_file': False, 'filename': 'CHANGELOG.md', "
182-
"'glob': None, 'key_path': None}]"
183-
),
184-
}
185-
186-
18762
def test_bump_nested_regex(tmp_path: Path, fixtures_path: Path, caplog):
18863
"""
18964
Arrange/Act: Run the `bump` subcommand with --no-configured-files.

tests/test_cli/test_legacy.py

-22
This file was deleted.

0 commit comments

Comments
 (0)