diff --git a/CHANGELOG.md b/CHANGELOG.md index ebab979..b1660da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file - can now handle other text surrounding a pep440-compliant version number, which will not be modified - can now handle pre-releases correctly. The version to increment is the most recent version in the log with a valid pep440 version number in it. - Release increment and prerelease increments can be mixed, allowing e.g: `yaclog release -mr` to create a release candidate with in incremented minor version number. +- `release` base version is now an argument instead of an option, for consistency with other commands. ### Removed diff --git a/tests/test_cli.py b/tests/test_cli.py index c6aa368..6a36e54 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -135,7 +135,7 @@ class TestRelease(unittest.TestCase): runner.invoke(cli, ['init']) # create the changelog runner.invoke(cli, ['entry', '-b', 'entry number 1']) - result = runner.invoke(cli, ['release', '--version', '1.0.0']) + result = runner.invoke(cli, ['release', '1.0.0']) check_result(self, result) self.assertEqual(yaclog.read(location).versions[0].name, '1.0.0') self.assertIn('1.0.0', result.output) @@ -178,6 +178,11 @@ class TestRelease(unittest.TestCase): self.assertEqual(yaclog.read(location).versions[0].name, '3.0.0rc1') self.assertIn('3.0.0rc1', result.output) + result = runner.invoke(cli, ['release', '-r']) + check_result(self, result) + self.assertEqual(yaclog.read(location).versions[0].name, '3.0.0rc2') + self.assertIn('3.0.0rc1', result.output) + result = runner.invoke(cli, ['release', '-f']) check_result(self, result) self.assertEqual(yaclog.read(location).versions[0].name, '3.0.0') @@ -199,7 +204,7 @@ class TestRelease(unittest.TestCase): runner.invoke(cli, ['init']) # create the changelog runner.invoke(cli, ['entry', '-b', 'entry number 1']) - result = runner.invoke(cli, ['release', '--version', '1.0.0', '-c'], input='y\n') + result = runner.invoke(cli, ['release', '1.0.0', '-c'], input='y\n') check_result(self, result) self.assertIn('Created commit', result.output) self.assertIn('Created tag', result.output) diff --git a/yaclog/cli/__main__.py b/yaclog/cli/__main__.py index c5ab22f..091d7e4 100644 --- a/yaclog/cli/__main__.py +++ b/yaclog/cli/__main__.py @@ -66,7 +66,8 @@ def reformat(obj: Changelog): help='Show version header and body.') @click.option('--name', '-n', 'str_func', flag_value=lambda v, k: v.name, help='Show only the version name') @click.option('--body', '-b', 'str_func', flag_value=lambda v, k: v.body(**k), help='Show only the version body.') -@click.option('--header', '-h', 'str_func', flag_value=lambda v, k: v.preamble(**k), help='Show only the version header.') +@click.option('--header', '-h', 'str_func', flag_value=lambda v, k: v.preamble(**k), + help='Show only the version header.') @click.argument('version_names', metavar='VERSIONS', type=str, nargs=-1) @click.pass_obj def show(obj: Changelog, all_versions, markdown, str_func, version_names): @@ -168,7 +169,6 @@ def entry(obj: Changelog, bullets, paragraphs, section_name, version_name): @cli.command(short_help='Release versions.') -@click.option('-v', '--version', 'version_name', type=str, default=None, help='The new version number to use.') @click.option('-M', '--major', 'rel_seg', flag_value=0, default=None, help='Increment major version number.') @click.option('-m', '--minor', 'rel_seg', flag_value=1, help='Increment minor version number.') @click.option('-p', '--patch', 'rel_seg', flag_value=2, help='Increment patch number.') @@ -179,9 +179,15 @@ def entry(obj: Changelog, bullets, paragraphs, section_name, version_name): @click.option('-c', '--commit', is_flag=True, help='Create a git commit tagged with the new version number. ' 'If there are no changes to commit, the current commit will be tagged instead.') +@click.argument('version_name', metavar='VERSION', type=str, default=None, required=False) @click.pass_obj def release(obj: Changelog, version_name, rel_seg, pre_seg, commit): - """Release versions in the changelog and increment their version numbers""" + """ + Release versions in the changelog and increment their version numbers. + + VERSION is the name of the version to release. If VERSION is not provided but increment options are, then the most + recent released version (PEP440 version without any prerelease information) is used instead. + """ if rel_seg is None and pre_seg is None and not version_name and not commit: click.echo('Nothing to release!')