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

Workflow now runs on multiple OS #63

Closed
wants to merge 4 commits into from
Closed
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
8 changes: 8 additions & 0 deletions chasten/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,14 @@ def log() -> None:
# of the chasten tool
server.start_syslog_server()

@cli.command()
def version():
"""Display the version of Chasten."""
# Get Chasten version from util file
version_string = util.get_chasten_version()
# output chasten version
typer.echo(f"{version_string}")


# ---
# End region: Command-line interface functions }}}
Expand Down
11 changes: 10 additions & 1 deletion chasten/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Utilities for use within chasten."""

import importlib.metadata
import pkg_resources

from chasten import constants

Expand Down Expand Up @@ -40,7 +41,15 @@ def get_chasten_version() -> str:
# there is not a working package that importlib.metadata can access with a version;
# in this situation the function should return the default value of 0.0.0
except importlib.metadata.PackageNotFoundError:
version_string_of_foo = default_chasten_semver
try:
# if importlib.metadata fails, try using pkg_resources
# The 'distribution' variable holds information about the 'chasten' package
distribution= pkg_resources.get_distribution(constants.chasten.Application_Name)
# Retrieve version information from distribution
version_string_of_foo= distribution.version
except pkg_resources.DistributionNotFound:
# If both methods fail, return a default version
version_string_of_foo = default_chasten_semver.version
return version_string_of_foo


Expand Down
Loading
Loading