Add output formatters
This commit is contained in:
24
depaudit/output/factory.py
Normal file
24
depaudit/output/factory.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from depaudit.output import Formatter
|
||||||
|
from depaudit.output.json_formatter import JSONFormatter
|
||||||
|
from depaudit.output.table_formatter import TableFormatter
|
||||||
|
|
||||||
|
|
||||||
|
class FormatterFactory:
|
||||||
|
@staticmethod
|
||||||
|
def get_formatter(
|
||||||
|
format_type: str,
|
||||||
|
use_color: bool = True,
|
||||||
|
verbosity: str = "info",
|
||||||
|
) -> Formatter:
|
||||||
|
formatters = {
|
||||||
|
"json": JSONFormatter,
|
||||||
|
"table": TableFormatter,
|
||||||
|
"quiet": TableFormatter,
|
||||||
|
}
|
||||||
|
|
||||||
|
formatter_class = formatters.get(format_type, TableFormatter)
|
||||||
|
return formatter_class(use_color=use_color, verbosity=verbosity)
|
||||||
Reference in New Issue
Block a user