Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions scripts/codelens.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,8 +889,12 @@ def main():
# graph-producing commands (scan/trace/impact/circular); other commands
# produce a single-node placeholder so the format is always valid.
if "format" not in existing_dests:
sub.add_argument("--format", "-f", choices=["json", "markdown", "ai", "sarif", "compact", "graphml"], default=None,
help="Output format: json, markdown, ai (normalized schema), sarif (GitHub/VS Code), compact (token-efficient single-char keys), or graphml (GraphML 1.0 XML for graph-producing commands)")
sub.add_argument("--format", "-f",
choices=["json", "markdown", "ai", "sarif", "compact", "graphml",
# Phase 2 (issue #52): 5 new formatters
"text", "junit-xml", "emacs", "vim", "gitlab-sast"],
default=None,
help="Output format: json, markdown, ai (normalized schema), sarif (GitHub/VS Code), compact (token-efficient single-char keys), graphml (GraphML 1.0 XML for graph-producing commands), text (human-readable table), junit-xml (Jenkins/GitLab CI), emacs (compile-mode), vim (quickfix), or gitlab-sast (GitLab security dashboard)")

# Add AI-optimized flags to subparser ONLY if the command doesn't already have them
if "top" not in existing_dests:
Expand Down
23 changes: 22 additions & 1 deletion scripts/formatters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,17 @@ def _normalize_to_ai(data: Any, command: str = "") -> Dict[str, Any]:

def format_output(data: Any, format_type: str = "json", command: str = "",
workspace: str = "") -> str:
"""Format output data as JSON, Markdown, AI (normalized schema), SARIF, Compact, or GraphML.
"""Format output data as JSON, Markdown, AI (normalized schema), SARIF, Compact, GraphML, or Phase 2 formatters.

GraphML (issue #59 Phase 3) emits a GraphML 1.0 XML document for
graph-producing commands (scan, trace, impact, circular). Non-graph
commands produce a single-node placeholder graph so the format is
always valid XML.

Phase 2 (issue #52) added: ``text``, ``junit-xml``, ``emacs``,
``vim``, ``gitlab-sast``. These consume :class:`formatters.base.Finding`
objects via :func:`formatters.base.extract_findings` — single
extraction path, consistent across all Phase 2 formatters.
"""
if format_type == "ai":
normalized = _normalize_to_ai(data, command)
Expand All @@ -213,5 +218,21 @@ def format_output(data: Any, format_type: str = "json", command: str = "",
# placeholder so the format is always valid, never raises.
from formatters.graphml import format_graphml
return format_graphml(data, command, workspace)
# ─── Phase 2 formatters (issue #52) ───
if format_type == "text":
from formatters.text import format_text
return format_text(data, command, workspace)
if format_type == "junit-xml":
from formatters.junit_xml import format_junit_xml
return format_junit_xml(data, command, workspace)
if format_type == "emacs":
from formatters.emacs import format_emacs
return format_emacs(data, command, workspace)
if format_type == "vim":
from formatters.vim import format_vim
return format_vim(data, command, workspace)
if format_type == "gitlab-sast":
from formatters.gitlab_sast import format_gitlab_sast
return format_gitlab_sast(data, command, workspace)
# Default: JSON
return json.dumps(data, indent=2, ensure_ascii=False)
Loading
Loading