🛠️ rson-cli
Command-line tools for RSON (Rust Serialized Object Notation)
🎯 What is rson-cli?
rson-cli provides powerful command-line tools for working with RSON files:
rsonc- The main RSON compiler/converter tool- Format and lint RSON files
- Convert between RSON and JSON
- Validate RSON syntax and structure
- Minify and pretty-print RSON data
Perfect for CI/CD pipelines, development workflows, and automation!
🚀 Installation
From Crates.io
From Source
Verify Installation
# rson-cli 0.1.0
📖 Usage
Basic Commands
# Format an RSON file
# Convert RSON to JSON
# Convert JSON to RSON
# Validate RSON syntax
# Minify RSON (remove comments, whitespace)
🔧 Commands Reference
rsonc format
Pretty-print and format RSON files with consistent style.
# Format a single file
# Format multiple files
# Format in-place (overwrite original)
# Custom indentation
# Output to stdout
Example:
# Before formatting
)
# After formatting
)
rsonc convert
Convert between RSON and JSON formats.
# RSON to JSON
# JSON to RSON
# Pretty-print output
# Minify output
Example:
# Convert RSON with comments to JSON
)
)
{
}
rsonc validate
Validate RSON files for syntax errors and structural issues.
# Validate single file
# Validate multiple files
# Strict validation (no warnings)
# Show detailed errors
Example:
|
| )
|
|
rsonc minify
Remove comments, whitespace, and trailing commas to create compact RSON.
# Minify file
# Minify to specific output
# Minify multiple files
Example:
# Before minifying
)
# After minifying
)
rsonc info
Show information about RSON files.
# Basic file info
# Detailed analysis
# Statistics only
Example:
)
⚙️ Configuration
Global Options
# Verbose output
# Quiet mode (suppress non-error output)
# Custom config file
# Force operation (ignore warnings)
Configuration File
Create .rsonc.toml in your project root:
# .rsonc.toml
[]
= 2
= true
= false
= 100
[]
= false
= true
= true
[]
= true
= true
🔄 CI/CD Integration
GitHub Actions
name: RSON Validation
on:
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install rson-cli
run: cargo install rson-cli
- name: Validate RSON files
run: rsonc validate --strict config/*.rson
- name: Check formatting
run: |
rsonc format --check config/*.rson
if [ $? -ne 0 ]; then
echo "RSON files need formatting. Run: rsonc format config/*.rson"
exit 1
fi
Pre-commit Hook
#!/bin/bash
# .git/hooks/pre-commit
# Validate all RSON files
if [; then
fi
# Auto-format RSON files
📊 Performance
rson-cli is built for speed:
| Operation | Speed | Memory |
|---|---|---|
| Format | ~50MB/s | Low |
| Validate | ~100MB/s | Minimal |
| Convert | ~30MB/s | Low |
| Minify | ~80MB/s | Minimal |
Benchmarks on typical configuration files
🎨 Examples
Batch Processing
# Format all RSON files in a directory
# Convert all JSON configs to RSON
for; do
done
# Validate all RSON files and collect errors
Development Workflow
# Watch for changes and auto-format
|
# Convert JSON API response to RSON for inspection
|
# Quick validation with detailed output
||
Build Scripts
#!/bin/bash
# build.sh
||
for; do
json_file="dist/config/.json"
done
🐛 Error Handling
rson-cli provides clear, actionable error messages:
|
|
| }
|
| )
)
📖 Documentation
- CLI Documentation - Complete API reference
- RSON Specification - Language specification
- Examples - Usage examples
🤝 Contributing
We welcome contributions! Please see our Contributing Guide.
Areas we need help with:
- Additional CLI commands
- Performance optimizations
- Better error messages
- Shell completion scripts
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🔗 Related Projects
- rson-core - Core RSON parsing library
- serde_rson - Serde integration for RSON
- rson-schema - Schema validation
- RSON Website - Documentation and playground
Made with 🛠️ by the RSON community