Initial upload of ai-code-audit-cli project
Some checks failed
Some checks failed
This commit is contained in:
84
src/cli/options.py
Normal file
84
src/cli/options.py
Normal file
@@ -0,0 +1,84 @@
|
||||
"""Shared CLI options and enums for AI Code Audit CLI."""
|
||||
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class OutputFormat(Enum):
|
||||
"""Output format options."""
|
||||
|
||||
TERMINAL = "terminal"
|
||||
JSON = "json"
|
||||
MARKDOWN = "markdown"
|
||||
|
||||
|
||||
class SeverityLevel(Enum):
|
||||
"""Severity levels for issues."""
|
||||
|
||||
LOW = "low"
|
||||
MEDIUM = "medium"
|
||||
HIGH = "high"
|
||||
CRITICAL = "critical"
|
||||
|
||||
|
||||
class LanguageType(Enum):
|
||||
"""Supported programming languages."""
|
||||
|
||||
PYTHON = "python"
|
||||
JAVASCRIPT = "javascript"
|
||||
TYPESCRIPT = "typescript"
|
||||
|
||||
|
||||
class ScanOptions:
|
||||
"""Options for scanning operations."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
output_format: OutputFormat = OutputFormat.TERMINAL,
|
||||
language_filter: Optional[LanguageType] = None,
|
||||
severity_filter: Optional[SeverityLevel] = None,
|
||||
verbose: bool = False,
|
||||
no_color: bool = False,
|
||||
quiet: bool = False,
|
||||
output_file: Optional[str] = None,
|
||||
):
|
||||
self.output_format = output_format
|
||||
self.language_filter = language_filter
|
||||
self.severity_filter = severity_filter
|
||||
self.verbose = verbose
|
||||
self.no_color = no_color
|
||||
self.quiet = quiet
|
||||
self.output_file = output_file
|
||||
|
||||
|
||||
def resolve_output_format(value: Optional[str]) -> OutputFormat:
|
||||
"""Resolve output format from string value."""
|
||||
if value is None:
|
||||
return OutputFormat.TERMINAL
|
||||
value_lower = value.lower()
|
||||
for fmt in OutputFormat:
|
||||
if fmt.value == value_lower:
|
||||
return fmt
|
||||
return OutputFormat.TERMINAL
|
||||
|
||||
|
||||
def resolve_severity(value: Optional[str]) -> Optional[SeverityLevel]:
|
||||
"""Resolve severity level from string value."""
|
||||
if value is None:
|
||||
return None
|
||||
value_lower = value.lower()
|
||||
for sev in SeverityLevel:
|
||||
if sev.value == value_lower:
|
||||
return sev
|
||||
return None
|
||||
|
||||
|
||||
def resolve_language(value: Optional[str]) -> Optional[LanguageType]:
|
||||
"""Resolve language type from string value."""
|
||||
if value is None:
|
||||
return None
|
||||
value_lower = value.lower()
|
||||
for lang in LanguageType:
|
||||
if lang.value == value_lower:
|
||||
return lang
|
||||
return None
|
||||
Reference in New Issue
Block a user