Skip to content

Commit

Permalink
Change: Restructure argument parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
n-thumann authored and greenbonebot committed Nov 10, 2023
1 parent 33748b0 commit 6a441c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions pontos/nvd/cve_changes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import asyncio
from argparse import ArgumentParser, Namespace
from typing import Callable

from pontos.nvd.cve_changes.api import CVEChangesApi

Expand All @@ -19,20 +18,23 @@ async def query_changes(args: Namespace) -> None:
print(cve)


def cve_changes() -> None:
def parse_args() -> Namespace:
parser = ArgumentParser()
parser.add_argument("--token", help="API key to use for querying.")
parser.add_argument("--cve-id", help="Get changes for a specific CVE")
parser.add_argument(
"--event-name", help="Get all CVE associated with a specific event name"
)
return parser.parse_args()

main(parser, query_changes)


def main(parser: ArgumentParser, func: Callable) -> None:
def main() -> None:
try:
args = parser.parse_args()
asyncio.run(func(args))
args = parse_args()
asyncio.run(query_changes(args))
except KeyboardInterrupt:
pass


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pontos-github-actions = 'pontos.github.actions:main'
pontos-github-script = 'pontos.github.script:main'
pontos-nvd-cve = 'pontos.nvd.cve:cve_main'
pontos-nvd-cves = 'pontos.nvd.cve:cves_main'
pontos-nvd-cve-changes = 'pontos.nvd.cve_changes:cve_changes'
pontos-nvd-cve-changes = 'pontos.nvd.cve_changes:main'
pontos-nvd-cpe = 'pontos.nvd.cpe:cpe_main'
pontos-nvd-cpes = 'pontos.nvd.cpe:cpes_main'

Expand Down

0 comments on commit 6a441c1

Please sign in to comment.