Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a --version option #341

Merged
merged 1 commit into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"))