Skip to content
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
13 changes: 11 additions & 2 deletions src/blurb/blurb.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,13 @@ def get_subcommand(subcommand):



@subcommand
def version():
"""Print blurb version."""
print("blurb version", __version__)



@subcommand
def help(subcommand=None):
"""
Expand Down Expand Up @@ -816,8 +823,10 @@ def help(subcommand=None):
print(doc)
sys.exit(0)

# Make "blurb --help" work.
# Make "blurb --help/--version/-V" work.
subcommands["--help"] = help
subcommands["--version"] = version
subcommands["-V"] = version


@subcommand
Expand Down Expand Up @@ -1205,7 +1214,7 @@ def main():
fn = get_subcommand(subcommand)

# hack
if fn in (test, help):
if fn in (help, test, version):
sys.exit(fn(*args))

try:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_blurb.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,12 @@ def test_extract_next_filename(news_entry, expected_path, fs):

# Assert
assert path == expected_path


def test_version(capfd):
# Act
blurb.version()

# Assert
captured = capfd.readouterr()
assert captured.out.startswith("blurb version ")
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ commands =
{posargs}
blurb test
blurb help
blurb --version
{envpython} -I -m blurb test
{envpython} -I -m blurb help
{envpython} -I -m blurb version