Skip to content

Commit

Permalink
Merge pull request #341 from tomschr/feature/339-version
Browse files Browse the repository at this point in the history
Provide a --version option for CLI.
  • Loading branch information
adiroiban authored Apr 15, 2021
2 parents b8a3490 + d5dae8d commit 61681d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/towncrier/_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
from .build import _main as _build_cmd
from .check import _main as _check_cmd
from .create import _main as _create_cmd
from ._version import __version__


@click.group(cls=DefaultGroup, default="build", default_if_no_args=True)
@click.version_option(__version__.public())
def cli():
pass

Expand Down
1 change: 1 addition & 0 deletions src/towncrier/newsfragments/339.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
towncrier --version` was added to the command line interface to show the product version.
9 changes: 8 additions & 1 deletion src/towncrier/test/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ def test_dash_m(self):
os.makedirs("news")
out = check_output([sys.executable, "-m", "towncrier", "--help"])
self.assertIn(b"[OPTIONS] COMMAND [ARGS]...", out)
self.assertIn(b"--help Show this message and exit.", out)
self.assertRegex(out, br".*--help\s+Show this message and exit.")
finally:
os.chdir(orig_dir)

def test_version(self):
"""
`--version` command line option is available to show the current production version.
"""
out = check_output(["towncrier", "--version"])
self.assertTrue(out.startswith(b"towncrier, version 2"))

0 comments on commit 61681d6

Please sign in to comment.