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
15 changes: 15 additions & 0 deletions polyapi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
CLI_COMMANDS = ["setup", "generate", "function", "clear", "help", "update_rendered_spec"]


def _get_version_string():
"""Get the version string for the package."""
try:
import importlib.metadata
version = importlib.metadata.version('polyapi-python')
return version
except Exception:
return "Unknown"


def execute_from_cli():
# First we setup all our argument parsing logic
# Then we parse the arguments (waaay at the bottom)
Expand All @@ -22,6 +32,11 @@ def execute_from_cli():
description="Manage your Poly API configurations and functions",
formatter_class=argparse.RawTextHelpFormatter
)

# Add global --version/-v flag
parser.add_argument('-v', '--version', action='version',
version=_get_version_string(),
help="Show version information")

subparsers = parser.add_subparsers(help="Available commands")

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"]

[project]
name = "polyapi-python"
version = "0.3.8.dev6"
version = "0.3.8.dev7"
description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers"
authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }]
dependencies = [
Expand Down