How mikefarah/yq works
Main Components
a. Core Processing Components:
• Command Line Interface (cmd/)
• Expression Engine (pkg/yqlib/expression_*.go)
• Operators System (pkg/yqlib/operator_*.go)
• Data Processing Pipeline
b. Input/Output Components:
• Multiple Format Decoders (YAML, JSON, XML, CSV, TOML, Properties)
• Multiple Format Encoders
• File Handling System
c. Evaluation Components:
• Stream Evaluator
• All-at-once Evaluator
• String Evaluator
[User Input] → [Command Line Interface]
• ↓
[Input Files] → [Format Decoders] → [Expression Engine] → [Format Encoders] → [Output]
• ↑ ↓ ↑
• [File Handler] [Operator System] [Writer System]
• ↓
• [Evaluation System]
Component Relationships
• Double lines: Primary processing path
Detailed Component Breakdown
Expression Engine:
[Expression Parser] → [Lexer] → [Operator Chain] → [Expression Evaluator]
Format Handling:
[Input] → [Format Detection] → [Appropriate Decoder] → [Internal Representation]
• ↓ ↓
[Output] ← [Format Encoder] ← [Writer] ← [Processed Data]
Additional Elements
• Configuration handling
• Error management
• Documentation generation
• Testing framework integration
Technical Details
Technical specifications:
• Go-based implementation
• Portable binary output
• Command-line interface
• Multiple format support
Integration Points
Integration with:
• Shell environments
• CI/CD systems (GitHub Actions)
• Container platforms (Docker/Podman)
The pipeline-based processing approach
Remember to include version information and any significant architectural changes between major versions, as this helps maintain historical context and understanding of the system's evolution.