Skip to content

Commit

Permalink
Modified the group command back to a single command.
Browse files Browse the repository at this point in the history
Will eventually change to a group command, but later.
  • Loading branch information
coordt committed Apr 9, 2023
1 parent fbf85c2 commit 6d4179b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
25 changes: 13 additions & 12 deletions bumpversion/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

import rich_click as click

# from click.core import Context
from bumpversion import __version__
from bumpversion.aliases import AliasedGroup

# from bumpversion.aliases import AliasedGroup
from bumpversion.bump import do_bump
from bumpversion.config import find_config_file, get_configuration
from bumpversion.logging import setup_logging
Expand All @@ -14,14 +16,17 @@
logger = logging.getLogger(__name__)


@click.group(cls=AliasedGroup)
@click.version_option(version=__version__)
def cli() -> None:
"""Version bump your Python project."""
pass
# @click.group(cls=AliasedGroup)
# @click.version_option(version=__version__)
# @click.pass_context
# def cli(ctx: Context) -> None:
# """Version bump your Python project."""
# if ctx.invoked_subcommand is None:
# ctx.invoke(bump)


@cli.command(context_settings={"ignore_unknown_options": True})
@click.command(context_settings={"ignore_unknown_options": True})
@click.version_option(version=__version__)
@click.argument("version_part")
@click.argument("files", nargs=-1, type=click.Path())
@click.option(
Expand Down Expand Up @@ -135,7 +140,7 @@ def cli() -> None:
required=False,
help="Extra arguments to commit command",
)
def bump(
def cli(
version_part: str,
files: list,
config_file: Optional[str],
Expand Down Expand Up @@ -199,7 +204,3 @@ def _log_list(config: dict, new_version: str) -> None:
logger.info("new_version=%s", new_version)
for key, value in config.items():
logger.info("%s=%s", key, value)


if __name__ == "__main__":
cli()
6 changes: 2 additions & 4 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ def test_bump_no_configured_files(mocker, tmp_path):
mocked_do_bump = mocker.patch("bumpversion.cli.do_bump")
runner: CliRunner = CliRunner()
with inside_dir(tmp_path):
result: Result = runner.invoke(
cli.cli, ["bump", "--current-version", "1.0.0", "--no-configured-files", "patch"]
)
result: Result = runner.invoke(cli.cli, ["--current-version", "1.0.0", "--no-configured-files", "patch"])

if result.exit_code != 0:
print(result.output)
Expand All @@ -47,7 +45,7 @@ def test_no_configured_files_still_file_args_work(mocker, tmp_path):
runner: CliRunner = CliRunner()
with inside_dir(tmp_path):
result: Result = runner.invoke(
cli.cli, ["bump", "--current-version", "1.0.0", "--no-configured-files", "patch", "do-this-file.txt"]
cli.cli, ["--current-version", "1.0.0", "--no-configured-files", "patch", "do-this-file.txt"]
)

if result.exit_code != 0:
Expand Down

0 comments on commit 6d4179b

Please sign in to comment.