You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Suppress script output in JSON mode for clean parsing
Resolves Issue #28 (Issue 1) by making --json output parseable with jq
and other JSON tools.
Problem:
- Script stdout/stderr mixed with JSON output
- Broke jq parsing: `./bin/xdebug-profile --json -- php script.php | jq`
- Prevented piping to other JSON processing tools
- Common error: "parse error: Invalid numeric literal"
Solution:
- In JSON mode, redirect script output to /dev/null
- Keep exit code for error detection
- Use passthru() for human mode (show script output)
- Use exec() for JSON mode (suppress script output)
Benefits:
- ✅ Clean JSON output for jq: `... | jq '.["🎯 bottleneck_functions"]'`
- ✅ MCP-compatible: pure JSON response
- ✅ Tool-friendly: easy to integrate with other tools
- ✅ Backward compatible: human mode unchanged
Changes:
- bin/xdebug-profile: Conditional output suppression in JSON mode
- docs/TROUBLESHOOTING.md: Added JSON parsing issue and solution
- Updated --help text with clear behavior explanation
- Added jq usage example to help text
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
0 commit comments