Skip to content

Commit

Permalink
Merge pull request #40 from frack113/pip_version
Browse files Browse the repository at this point in the history
Add update option
  • Loading branch information
thomaspatzke committed Dec 16, 2023
2 parents cd5e47e + 68ed9c7 commit 6c23960
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 61 deletions.
125 changes: 68 additions & 57 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions print-coverage.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Prints code testing coverage as percentage for badge generation.
import xml.etree.ElementTree as et
from defusedxml.ElementTree import parse

tree = et.parse("cov.xml")
tree = parse("cov.xml")
root = tree.getroot()
coverage = float(root.attrib["line-rate"]) * 100
print(f"COVERAGE={coverage:3.4}%")
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ packages = [
python = "^3.8"
click = "^8.0.3"
prettytable = "^3.1.1"
pysigma = "^0.10.4"
pysigma = "^0.10.10"
colorama = "^0.4.6"

[tool.poetry.dev-dependencies]
pytest = "^6.2.2"
pytest-cov = "^2.11.1"
defusedxml = "^0.7.1"

[tool.poetry.scripts]
sigma = "sigma.cli.main:main"
Expand Down
21 changes: 20 additions & 1 deletion sigma/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import click
import sys
import requests
from packaging.version import Version

try:
import sigma.parser.base
Expand Down Expand Up @@ -42,7 +44,24 @@ def cli():
@click.command()
def version():
"""Print version of Sigma CLI."""
click.echo(metadata.version("sigma-cli"))
try:
data = requests.get("https://pypi.org/pypi/sigma-cli/json").json()
versions = list(data["releases"].keys())
versions.sort(key=Version, reverse=True)
last_version = versions[0]
except:
last_version = "0.0.0"

current_version = metadata.version("sigma-cli")
if last_version == "0.0.0":
click.echo(current_version)
else:
color = "green" if last_version == current_version else "red"
click.echo(
f"{current_version} (online pypi.org: "
+ click.style(last_version, bold=True, fg=color)
+ ")"
)


def main():
Expand Down
Loading

0 comments on commit 6c23960

Please sign in to comment.