Skip to content

Commit

Permalink
Add extensions to the version output (#411)
Browse files Browse the repository at this point in the history
This change adds distribution extension name and version to the
--version CLI argument output. So if an extension is being used with
this CLI, it should list it as long as it begins with "precli-".

Signed-off-by: Eric Brown <eric.brown@securesauce.dev>
  • Loading branch information
ericwb committed Apr 3, 2024
1 parent 39b5b56 commit 1b6c3bc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions precli/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import tempfile
import zipfile
from importlib import metadata
from urllib.parse import urljoin
from urllib.parse import urlparse

Expand Down Expand Up @@ -117,11 +118,16 @@ def setup_arg_parser():
action="store_true",
help="quiet mode, display less output",
)
extensions = ""
for dist in metadata.distributions():
if dist.name.startswith("precli-"):
extensions += f" {dist.name} {dist.version}\n"
python_ver = sys.version.replace("\n", "")
parser.add_argument(
"--version",
action="version",
version=f"precli {precli.__version__}\n"
f"{extensions}"
f"Copyright 2024 Secure Saurce LLC\n"
f"License BUSL-1.1: Business Source License 1.1 <{BUSL_URL}>\n"
f" Python {python_ver}",
Expand Down

0 comments on commit 1b6c3bc

Please sign in to comment.