fy
Fast YAML command-line processor with validation and linting. Built on fast-yaml for high-performance YAML 1.2.2 processing.
Installation
From crates.io
[!TIP] Use
cargo binstall fast-yaml-clifor faster installation without compilation.
From source
Verify installation
Usage
Parse and validate
# Parse from file
# Parse from stdin
|
# Show parse statistics
Format YAML
Single file:
# Format to stdout
# Custom indentation (2-8 spaces)
# Format in-place
Batch mode (directories, globs, multiple files):
# Format entire directory (recursive)
# Format with glob pattern
# Multiple files
# Non-recursive directory formatting
# Parallel processing with 8 workers
# Read file paths from stdin
|
[!TIP] Batch mode automatically detects when processing multiple files, directories, or glob patterns. Use
-j Nto control parallelism (default: auto-detect CPU cores).
Include/exclude patterns:
# Format all YAML except tests
# Format only production configs
# Combine patterns (respects .gitignore by default)
Dry run and output control:
# Preview changes without modifying files
# Quiet mode (only show errors)
# Verbose mode (show each file processed)
Convert formats
# YAML to JSON
# JSON to YAML
# Compact JSON (no pretty-print)
Lint YAML
# Lint with default rules
# Custom rules
# JSON output for IDE integration
Commands
| Command | Description |
|---|---|
parse |
Parse and validate YAML syntax |
format |
Format YAML with consistent style |
convert |
Convert between YAML and JSON |
lint |
Lint YAML with diagnostics |
Options
Common Options
| Option | Short | Description | Default |
|---|---|---|---|
--in-place |
-i |
Edit file in-place | - |
--output |
-o |
Write to file | stdout |
--format |
-f |
Output format (yaml/json/compact) | yaml |
--no-color |
- | Disable colored output | - |
--quiet |
-q |
Suppress non-error output | - |
--verbose |
-v |
Enable verbose output | - |
Batch Mode Options
| Option | Short | Description | Default |
|---|---|---|---|
--jobs |
-j |
Number of parallel workers (0 = auto) | auto-detect |
--stdin-files |
- | Read file paths from stdin | - |
--include |
- | Include pattern (glob) | all files |
--exclude |
- | Exclude pattern (glob) | none |
--no-recursive |
- | Disable recursive directory traversal | recursive |
--dry-run |
-n |
Preview changes without modifying | - |
[!NOTE] Batch mode activates automatically when processing multiple paths, directories, glob patterns, or when using
--stdin-files,--include,--exclude, or--jobs.
Features
| Feature | Default | Description |
|---|---|---|
colors |
Yes | Colored terminal output |
linter |
Yes | YAML linting capabilities |
all |
- | All features enabled |
Build with minimal features:
[!NOTE] The
linterfeature adds thelintcommand. Without it, onlyparse,format, andconvertare available.
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Parse error |
| 2 | Lint errors found |
| 3 | I/O error |
| 4 | Invalid arguments |
Examples
Pipeline usage
# Validate all YAML files
# Format and convert in one pipeline
| |
# Check YAML before committing
|
CI/CD integration
# GitHub Actions
- name: Validate YAML
run: |
cargo install fast-yaml-cli
find . -name "*.yaml" -exec fy lint {} \;
Performance
Built on fast-yaml-core for optimal performance:
- Startup time: ~5ms
- Binary size: ~1MB (stripped)
- Batch processing: Multi-threaded with automatic CPU detection
- Streaming: Memory-mapped I/O for files >512KB
- Full YAML 1.2.2 compliance
[!TIP] Batch mode provides 3-6x speedup on multi-core systems when processing 100+ files. Use
-j Nto control worker count.
License
Licensed under MIT or Apache-2.0 at your option.