From 6ba2dac7a9631ec44b97c3e79f3766531ef4103b Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Wed, 25 Oct 2023 11:32:12 +0200 Subject: [PATCH] Update CLI --- exasol/toolbox/tools/security.py | 18 ++++++++---------- exasol/toolbox/tools/tbx.py | 4 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/exasol/toolbox/tools/security.py b/exasol/toolbox/tools/security.py index ed5772e0..fad66eac 100644 --- a/exasol/toolbox/tools/security.py +++ b/exasol/toolbox/tools/security.py @@ -1,6 +1,5 @@ """This module contains security related CLI tools and code""" import json -from enum import Enum import re import subprocess import sys @@ -8,6 +7,7 @@ asdict, dataclass, ) +from enum import Enum from functools import partial from inspect import cleandoc from typing import ( @@ -36,7 +36,7 @@ class Issue: def _issues(input) -> Generator[Issue, None, None]: - lines = (l for l in input if l.strip() != '') + lines = (l for l in input if l.strip() != "") for line in lines: obj = json.loads(line) yield Issue(**obj) @@ -169,13 +169,13 @@ def create_security_issue(issue: Issue) -> Tuple[str, str]: class Format(str, Enum): - Maven = 'maven' + Maven = "maven" # pylint: disable=redefined-builtin @CVE_CLI.command(name="convert") def convert( - format: Format = typer.Argument(..., help="input format to be converted."), + format: Format = typer.Argument(..., help="input format to be converted."), ) -> None: def _maven(): issues = from_maven(sys.stdin.read()) @@ -189,14 +189,14 @@ def _maven(): class Filter(str, Enum): - Github = 'github' - PassThrough = 'pass-through' + Github = "github" + PassThrough = "pass-through" # pylint: disable=redefined-builtin @CVE_CLI.command(name="filter") def filter( - type: Filter = typer.Argument(help="filter type to apply"), + type: Filter = typer.Argument(help="filter type to apply"), ) -> None: """ Filter specific CVE's from the input @@ -217,16 +217,14 @@ def _github(): ] for issue in _issues_as_json_str(filtered_issues): stdout(issue) - raise typer.Exit(code=0) def _pass_through(): for line in sys.stdin: stdout(line) - raise typer.Exit(code=0) - actions = {Filter.Github: _github, Filter.PassThrough: _pass_through()} + actions = {Filter.Github: _github, Filter.PassThrough: _pass_through} action = actions[type] action() diff --git a/exasol/toolbox/tools/tbx.py b/exasol/toolbox/tools/tbx.py index b1c3c8f1..c9b9f3cc 100644 --- a/exasol/toolbox/tools/tbx.py +++ b/exasol/toolbox/tools/tbx.py @@ -6,8 +6,8 @@ ) CLI = typer.Typer() -CLI.add_typer(workflow.CLI, name="workflow", help='Manage github workflows') -CLI.add_typer(security.CLI, name="security", help='Security related helpers') +CLI.add_typer(workflow.CLI, name="workflow", help="Manage github workflows") +CLI.add_typer(security.CLI, name="security", help="Security related helpers") if __name__ == "__main__":